diff --git a/admin/index.php b/admin/index.php
index f5b4a6f85..d8667a155 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,330 +1,330 @@
title = $title;
$this->icon = $icon;
$this->href = $href;
$this->data_toggle = $data_toggle;
$this->data_target = $data_target;
if (!empty($href)) {
$fileName = basename($_SERVER["SCRIPT_NAME"]);
if ($href === $fileName) {
$this->active = true;
}
}
}
function addItem(MenuAdmin $menu) {
$this->itens[] = $menu;
if ($menu->active) {
$this->show = true;
}
}
}
$itens = array();
$menu = new MenuAdmin(__("Dashboard"), "fa fa-tachometer-alt", "dashboard");
$itens[] = $menu;
$menu = new MenuAdmin(__("Settings"), "fa fa-wrench");
$menu->addItem(new MenuAdmin(__("Remove Branding"), "far fa-edit", "customize_settings"));
$menu->addItem(new MenuAdmin(__("General Settings"), "fas fa-cog", "general_settings"));
$menu->addItem(new MenuAdmin(__("Site Settings"), "fas fa-sitemap", "site_settings"));
$menu->addItem(new MenuAdmin(__("Social Login Settings"), "fas fa-sign-in-alt", "socialLogin_settings"));
$menu->addItem(new MenuAdmin(__("S3, B2, FTP settings"), "fas fa-hdd", "storage_settings"));
$menu->addItem(new MenuAdmin(__("Payments Settings"), "far fa-money-bill-alt", "payments_settings"));
$itens[] = $menu;
$menu = new MenuAdmin(__("Contents"), "fas fa-list-ul");
$menu->addItem(new MenuAdmin(__("Videos"), "fas fa-play-circle", "videos"));
$menu->addItem(new MenuAdmin(__("Live Stuff"), "fas fa-broadcast-tower", "live"));
$menu->addItem(new MenuAdmin(__("Users"), "glyphicon glyphicon-user", "users"));
$menu->addItem(new MenuAdmin(__("Users Groups"), "fa fa-users", "usersGroups"));
$menu->addItem(new MenuAdmin(__("Categories"), "glyphicon glyphicon-list", "categories"));
$menu->addItem(new MenuAdmin(__("Backup"), "fas fa-undo-alt", "backup"));
$itens[] = $menu;
$menu = new MenuAdmin(__("Design"), "fas fa-pen-fancy");
$menu->addItem(new MenuAdmin(__("First Page Style"), "fas fa-columns", "design_first_page"));
$menu->addItem(new MenuAdmin(__("Player Skin"), "fas fa-play-circle", "design_player"));
$menu->addItem(new MenuAdmin(__("Themes"), "fas fa-palette", "design_themes"));
$menu->addItem(new MenuAdmin(__("Colors"), "fas fa-palette", "design_colors"));
//$menu->addItem(new MenuAdmin(__("Custom CSS"), "fab fa-css3-alt", "design_css"));
$itens[] = $menu;
$menu = new MenuAdmin(__("Monetize"), "fas fa-dollar-sign");
$menu->addItem(new MenuAdmin(__("Site Advertisement with VAST Video ads"), "fas fa-money-check-alt", "monetize_vast"));
$menu->addItem(new MenuAdmin(__("Pay User per Video View"), "far fa-money-bill-alt", "monetize_user"));
$menu->addItem(new MenuAdmin(__("Create Subscription Plans"), "fas fa-money-bill-alt", "monetize_subscription"));
//$menu->addItem(new MenuAdmin(__("Banner Script code"), "fas fa-money-check-alt", "advertisement_script"));
$itens[] = $menu;
/*
$menu = new MenuAdmin(__("Update Version"), "glyphicon glyphicon-refresh", "{$global['webSiteRootURL']}update/");
$itens[] = $menu;
*/
$menu = new MenuAdmin(__("Miscellaneous"), "fas fa-th");
$menu->addItem(new MenuAdmin(__("Plugins"), "fas fa-puzzle-piece", "plugins"));
$menu->addItem(new MenuAdmin(__("Email All Users"), "fas fa-mail-bulk", "mail_all_users"));
$itens[] = $menu;
$_GET['page'] = xss_esc(@$_GET['page']);
$includeHead = "";
$includeBody = "";
switch ($_GET['page']) {
case "backup":
$includeBody = $global['systemRootPath'] . 'admin/backup.php';
break;
case "design_first_page":
$includeBody = $global['systemRootPath'] . 'admin/design_first_page.php';
break;
case "design_themes":
$includeBody = $global['systemRootPath'] . 'admin/design_themes.php';
break;
case "design_colors":
$includeBody = $global['systemRootPath'] . 'admin/design_colors.php';
break;
case "design_player":
$includeBody = $global['systemRootPath'] . 'admin/design_player.php';
break;
case "customize_settings":
$includeBody = $global['systemRootPath'] . 'admin/customize_settings.php';
break;
case "storage_settings":
$includeBody = $global['systemRootPath'] . 'admin/storage_settings.php';
break;
case "general_settings":
$includeBody = $global['systemRootPath'] . 'admin/general_settings.php';
break;
case "payments_settings":
$includeBody = $global['systemRootPath'] . 'admin/payments_settings.php';
break;
case "socialLogin_settings":
$includeBody = $global['systemRootPath'] . 'admin/socialLogin_settings.php';
break;
case "site_settings":
$includeHead = $global['systemRootPath'] . 'view/configurations_head.php';
$includeBody = $global['systemRootPath'] . 'view/configurations_body.php';
break;
case "monetize_subscription":
$includeHead = $global['systemRootPath'] . 'plugin/Subscription/page/editor_head.php';
$includeBody = array();
$includeBody[] = $global['systemRootPath'] . 'plugin/Subscription/page/editor_body.php';
$includeBody[] = $global['systemRootPath'] . 'admin/monetize_subscription.php';
break;
case "monetize_vast":
$includeHead = $global['systemRootPath'] . 'plugin/AD_Server/index_head.php';
$includeBody = $global['systemRootPath'] . 'plugin/AD_Server/index_body.php';
break;
case "monetize_user":
$includeBody = $global['systemRootPath'] . 'admin/monetize_user.php';
break;
case "plugins":
$includeHead = $global['systemRootPath'] . 'view/managerPlugins_head.php';
$includeBody = $global['systemRootPath'] . 'view/managerPlugins_body.php';
break;
case "mail_all_users":
$includeBody = $global['systemRootPath'] . 'admin/mail_all_users.php';
break;
case "users":
$includeHead = $global['systemRootPath'] . 'view/managerUsers_head.php';
$includeBody = $global['systemRootPath'] . 'view/managerUsers_body.php';
break;
case "live":
$includeBody = $global['systemRootPath'] . 'admin/live.php';
break;
case "usersGroups":
$includeHead = $global['systemRootPath'] . 'view/managerUsersGroups_head.php';
$includeBody = $global['systemRootPath'] . 'view/managerUsersGroups_body.php';
break;
case "categories":
$includeHead = $global['systemRootPath'] . 'view/managerCategories_head.php';
$includeBody = $global['systemRootPath'] . 'view/managerCategories_body.php';
break;
case "videos":
$includeHead = $global['systemRootPath'] . 'view/managerVideos_head.php';
$includeBody = $global['systemRootPath'] . 'view/managerVideos_body.php';
break;
default :
$includeHead = $global['systemRootPath'] . 'view/charts_head.php';
$includeBody = $global['systemRootPath'] . 'view/charts_body.php';
break;
}
?>
- getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
";
include $includeHead;
echo "";
}
?>
diff --git a/locale/index.php b/locale/index.php
index d6c24c3a2..1f2e54514 100644
--- a/locale/index.php
+++ b/locale/index.php
@@ -1,206 +1,206 @@
$value) {
$vars[$matches[1][$key]] = $matches[1][$key];
}
}
}
}
closedir($handle);
}
}
listAll($global['systemRootPath']);
sort($vars);
?>
- getWebSiteTitle();?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
chown www-data:www-data locale && sudo chmod -R 755 locale
diff --git a/objects/configuration.php b/objects/configuration.php
index 9e0d0d82e..d9594a2c0 100644
--- a/objects/configuration.php
+++ b/objects/configuration.php
@@ -1,503 +1,508 @@
load();
if (!empty($video_resolution)) {
$this->video_resolution = $video_resolution;
}
}
function load() {
global $global;
$sql = "SELECT * FROM configurations WHERE id = 1 LIMIT 1";
//echo $sql;exit;
// add true because I was not getting the SMTP configuration on function setSiteSendMessage(&$mail)
$res = sqlDAL::readSql($sql, "", array(), true);
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res && !empty($result)) {
$config = $result;
//var_dump($config);exit;
foreach ($config as $key => $value) {
$this->$key = $value;
}
} else {
return false;
}
}
function save() {
global $global;
if (!User::isAdmin()) {
header('Content-Type: application/json');
die('{"error":"' . __("Permission denied") . '"}');
}
$this->users_id = User::getId();
ObjectYPT::deleteCache("getEncoderURL");
$sql = "UPDATE configurations SET "
. "video_resolution = '{$this->video_resolution}',"
. "webSiteTitle = '{$this->webSiteTitle}',"
. "language = '{$this->language}',"
. "contactEmail = '{$this->contactEmail}',"
. "users_id = '{$this->users_id}', "
. "authCanUploadVideos = '{$this->authCanUploadVideos}',"
. "authCanViewChart = '{$this->authCanViewChart}',"
. "authCanComment = '{$this->authCanComment}',"
. "encoderURL = '{$global['mysqli']->real_escape_string($this->_getEncoderURL())}',"
. "head = '{$global['mysqli']->real_escape_string($this->getHead())}',"
. "adsense = '{$global['mysqli']->real_escape_string($this->getAdsense())}',"
. "mode = '{$this->getMode()}',"
. "logo = '{$global['mysqli']->real_escape_string($this->getLogo())}',"
. "logo_small = '{$global['mysqli']->real_escape_string($this->getLogo_small())}',"
. "disable_analytics = '{$this->getDisable_analytics()}',"
. "disable_youtubeupload = '{$this->getDisable_youtubeupload()}',"
. "allow_download = '{$this->getAllow_download()}',"
. "session_timeout = '{$this->getSession_timeout()}',"
. "autoplay = '{$this->getAutoplay()}',"
. "theme = '{$global['mysqli']->real_escape_string($this->getTheme())}',"
. "smtp = '{$this->getSmtp()}',"
. "smtpAuth = '{$this->getSmtpAuth()}',"
. "smtpSecure = '{$global['mysqli']->real_escape_string($this->getSmtpSecure())}',"
. "smtpHost = '{$global['mysqli']->real_escape_string($this->getSmtpHost())}',"
. "smtpUsername = '{$global['mysqli']->real_escape_string($this->getSmtpUsername())}',"
. "smtpPort = '{$global['mysqli']->real_escape_string($this->getSmtpPort())}',"
. "smtpPassword = '{$global['mysqli']->real_escape_string($this->getSmtpPassword())}'"
. " WHERE id = 1";
return sqlDAL::writeSql($sql);
}
function getVideo_resolution() {
return $this->video_resolution;
}
function getUsers_id() {
return $this->users_id;
}
function getVersion() {
if (empty($this->version)) {
return " 0.1";
}
return $this->version;
}
function getWebSiteTitle() {
return $this->webSiteTitle;
}
function getLanguage() {
if ($this->language == "en") {
return "us";
}
return $this->language;
}
function getContactEmail() {
return $this->contactEmail;
}
function setVideo_resolution($video_resolution) {
$this->video_resolution = $video_resolution;
}
function setWebSiteTitle($webSiteTitle) {
$this->webSiteTitle = $webSiteTitle;
}
function setLanguage($language) {
$this->language = $language;
}
function setContactEmail($contactEmail) {
$this->contactEmail = $contactEmail;
}
function currentVersionLowerThen($version) {
return version_compare($version, $this->getVersion()) > 0;
}
function currentVersionGreaterThen($version) {
return version_compare($version, $this->getVersion()) < 0;
}
function currentVersionEqual($version) {
return version_compare($version, $this->getVersion()) == 0;
}
function getAuthCanUploadVideos() {
return $this->authCanUploadVideos;
}
function getAuthCanViewChart() {
return $this->authCanViewChart;
}
function getAuthCanComment() {
return $this->authCanComment;
}
function setAuthCanUploadVideos($authCanUploadVideos) {
$this->authCanUploadVideos = intval($authCanUploadVideos);
}
function setAuthCanViewChart($authCanViewChart) {
$this->authCanViewChart = $authCanViewChart;
}
function setAuthCanComment($authCanComment) {
$this->authCanComment = $authCanComment;
}
function getHead() {
return $this->head;
}
function getLogo($timestamp = false) {
global $global;
if (empty($this->logo)) {
return "view/img/logo.png";
}
$get = "";
$file = str_replace("?", "", $global['systemRootPath'] . $this->logo);
if ($timestamp && file_exists($file)) {
$get .= "?" . filemtime($file);
}
return $this->logo . $get;
}
static function _getFavicon($getPNG = false) {
global $global;
$file = false;
$url = false;
if (!$getPNG) {
$file = $global['systemRootPath'] . "videos/favicon.ico";
$url = "{$global['webSiteRootURL']}videos/favicon.ico";
if (!file_exists($file)) {
$file = $global['systemRootPath'] . "view/img/favicon.ico";
$url = "{$global['webSiteRootURL']}view/img/favicon.ico";
}
}
if (empty($url) || !file_exists($file)) {
$file = $global['systemRootPath'] . "videos/favicon.png";
$url = "{$global['webSiteRootURL']}videos/favicon.png";
if (!file_exists($file)) {
$file = $global['systemRootPath'] . "view/img/favicon.png";
$url = "{$global['webSiteRootURL']}view/img/favicon.png";
}
}
return array('file' => $file, 'url' => $url);
}
function getFavicon($getPNG = false, $getTime = true) {
$return = self::_getFavicon($getPNG);
if ($getTime) {
return $return['url'] . "?" . filemtime($return['file']);
} else {
return $return['url'];
}
}
static function getOGImage() {
global $global;
$destination = "{$global['systemRootPath']}videos/cache/og_200X200.jpg";
$return = self::_getFavicon(true);
convertImageToOG($return['file'], $destination);
return $global['webSiteRootURL'] . "videos/cache/og_200X200.jpg";
}
function setHead($head) {
$this->head = $head;
}
function setLogo($logo) {
$this->logo = $logo;
}
function getLogo_small() {
if (empty($this->logo_small)) {
return "view/img/logo32.png";
}
return $this->logo_small;
}
function setLogo_small($logo_small) {
$this->logo_small = $logo_small;
}
function getAdsense() {
return $this->adsense;
}
function setAdsense($adsense) {
$this->adsense = $adsense;
}
function getMode() {
if (empty($this->mode)) {
return 'Youtube';
}
return $this->mode;
}
function setMode($mode) {
$this->mode = $mode;
}
// version 2.7
function getDisable_analytics() {
return $this->disable_analytics;
}
function getDisable_youtubeupload() {
return $this->disable_youtubeupload;
}
function getAllow_download() {
return $this->allow_download;
}
function getSession_timeout() {
return $this->session_timeout;
}
function setDisable_analytics($disable_analytics) {
$this->disable_analytics = ($disable_analytics == 'true' || $disable_analytics == '1') ? 1 : 0;
}
function setDisable_youtubeupload($disable_youtubeupload) {
$this->disable_youtubeupload = ($disable_youtubeupload == 'true' || $disable_youtubeupload == '1') ? 1 : 0;
}
function setAllow_download($allow_download) {
$this->allow_download = ($allow_download == 'true' || $allow_download == '1') ? 1 : 0;
}
function setSession_timeout($session_timeout) {
$this->session_timeout = $session_timeout;
}
function getAutoplay() {
return intval($this->autoplay);
}
function setAutoplay($autoplay) {
$this->autoplay = ($autoplay == 'true' || $autoplay == '1') ? 1 : 0;
}
// end version 2.7
static function rewriteConfigFile() {
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase;
if (empty($global['salt'])) {
$global['salt'] = uniqid();
}
if (empty($global['disableTimeFix'])) {
$global['disableTimeFix'] = 0;
}
if (empty($global['logfile'])) {
$global['logfile'] = $global['systemRootPath'] . 'videos/avideo.log';
}
$content = "theme)) {
return "default";
}
return $this->theme;
}
function setTheme($theme) {
$this->theme = $theme;
}
function getSmtp() {
return intval($this->smtp);
}
function getSmtpAuth() {
return intval($this->smtpAuth);
}
function getSmtpSecure() {
return $this->smtpSecure;
}
function getSmtpHost() {
return $this->smtpHost;
}
function getSmtpUsername() {
return $this->smtpUsername;
}
function getSmtpPassword() {
return $this->smtpPassword;
}
function setSmtp($smtp) {
$this->smtp = ($smtp == 'true' || $smtp == '1') ? 1 : 0;
}
function setSmtpAuth($smtpAuth) {
$this->smtpAuth = ($smtpAuth == 'true' || $smtpAuth == '1') ? 1 : 0;
}
function setSmtpSecure($smtpSecure) {
$this->smtpSecure = $smtpSecure;
}
function setSmtpHost($smtpHost) {
$this->smtpHost = $smtpHost;
}
function setSmtpUsername($smtpUsername) {
$this->smtpUsername = $smtpUsername;
}
function setSmtpPassword($smtpPassword) {
$this->smtpPassword = $smtpPassword;
}
function getSmtpPort() {
return intval($this->smtpPort);
}
function setSmtpPort($smtpPort) {
$this->smtpPort = intval($smtpPort);
}
function _getEncoderURL() {
return $this->encoderURL;
}
function getEncoderURL() {
global $getEncoderURL;
if (empty($getEncoderURL)) {
$getEncoderURL = ObjectYPT::getCache("getEncoderURL", 60);
if (empty($getEncoderURL)) {
global $advancedCustom;
if (!empty($advancedCustom->useEncoderNetworkRecomendation) && !empty($advancedCustom->encoderNetwork)) {
if (substr($advancedCustom->encoderNetwork, -1) !== '/') {
$advancedCustom->encoderNetwork .= "/";
}
$bestEncoder = json_decode(url_get_contents($advancedCustom->encoderNetwork . "view/getBestEncoder.php", "", 10));
if (!empty($bestEncoder->siteURL)) {
$this->encoderURL = $bestEncoder->siteURL;
} else {
error_log("Configuration::getEncoderURL ERROR your network ($advancedCustom->encoderNetwork) is not configured properly This slow down your site a lot, disable the option useEncoderNetworkRecomendation in your CustomizeAdvanced plugin");
}
}
if (empty($this->encoderURL)) {
$getEncoderURL = "https://encoder1.avideo.com/";
}
if (substr($this->encoderURL, -1) !== '/') {
$this->encoderURL .= "/";
}
$getEncoderURL = $this->encoderURL;
ObjectYPT::setCache("getEncoderURL", $getEncoderURL);
}
}
return $getEncoderURL;
}
function setEncoderURL($encoderURL) {
$this->encoderURL = $encoderURL;
}
+
+ function getPageTitleSeparator() {
+ define("PAGE_TITLE_SEPARATOR", "·"); // This is ready to be configurable, if needed
+ return " " . PAGE_TITLE_SEPARATOR . " ";
+ }
}
diff --git a/objects/functions.php b/objects/functions.php
index 4e96b9b87..c282fd3ea 100644
--- a/objects/functions.php
+++ b/objects/functions.php
@@ -1,5093 +1,5125 @@
0 && $upload_max < $max_size) {
$max_size = $upload_max;
}
}
return $max_size;
}
function parse_size($size) {
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) {
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
} else {
return round($size);
}
}
function humanFileSize($size, $unit = "") {
if ((!$unit && $size >= 1 << 30) || $unit == "GB") {
return number_format($size / (1 << 30), 2) . "GB";
}
if ((!$unit && $size >= 1 << 20) || $unit == "MB") {
return number_format($size / (1 << 20), 2) . "MB";
}
if ((!$unit && $size >= 1 << 10) || $unit == "KB") {
return number_format($size / (1 << 10), 2) . "KB";
}
return number_format($size) . " bytes";
}
function get_max_file_size() {
return humanFileSize(file_upload_max_size());
}
function humanTiming($time, $precision = 0) {
if (!is_int($time)) {
$time = strtotime($time);
}
$time = time() - $time; // to get the time since that moment
return secondsToHumanTiming($time, $precision);
}
function humanTimingAgo($time, $precision = 0) {
if (!is_int($time)) {
$time = strtotime($time);
}
$time = time() - $time; // to get the time since that moment
if (empty($time)) {
return __("Now");
}
return secondsToHumanTiming($time, $precision) . " " . __("ago");
}
function secondsToHumanTiming($time, $precision = 0) {
if (empty($time)) {
return __("Now");
}
$time = ($time < 0) ? $time * -1 : $time;
$time = ($time < 1) ? 1 : $time;
$tokens = array(
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second',
);
/**
* For detection propouse only
*/
__('year');
__('month');
__('week');
__('day');
__('hour');
__('minute');
__('second');
__('years');
__('months');
__('weeks');
__('days');
__('hours');
__('minutes');
__('seconds');
foreach ($tokens as $unit => $text) {
if ($time < $unit) {
continue;
}
$numberOfUnits = floor($time / $unit);
if ($numberOfUnits > 1) {
$text = __($text . "s");
} else {
$text = __($text);
}
if ($precision) {
$rest = $time % $unit;
if ($rest) {
$text .= ' ' . secondsToHumanTiming($rest, $precision - 1);
}
}
return $numberOfUnits . ' ' . $text;
}
}
function checkVideosDir() {
$dir = "../videos";
if (file_exists($dir)) {
return is_writable($dir);
}
return mkdir($dir);
}
function isApache() {
return (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false);
}
function isPHP($version = "'7.0.0'") {
return (version_compare(PHP_VERSION, $version) >= 0);
}
function modEnabled($mod_name) {
if (!function_exists('apache_get_modules')) {
ob_start();
phpinfo(INFO_MODULES);
$contents = ob_get_contents();
ob_end_clean();
return (strpos($contents, 'mod_' . $mod_name) !== false);
}
return in_array('mod_' . $mod_name, apache_get_modules());
}
function modRewriteEnabled() {
return modEnabled("rewrite");
}
function modAliasEnabled() {
return modEnabled("alias");
}
function isFFMPEG() {
return trim(shell_exec('which ffmpeg'));
}
function isUnzip() {
return trim(shell_exec('which unzip'));
}
function isExifToo() {
return trim(shell_exec('which exiftool'));
}
function getPathToApplication() {
return str_replace("install/index.php", "", $_SERVER["SCRIPT_FILENAME"]);
}
function getURLToApplication() {
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = explode("install/index.php", $url);
return $url[0];
}
//max_execution_time = 7200
function check_max_execution_time() {
$max_size = ini_get('max_execution_time');
$recomended_size = 7200;
return ($recomended_size <= $max_size);
}
//post_max_size = 100M
function check_post_max_size() {
$max_size = parse_size(ini_get('post_max_size'));
$recomended_size = parse_size('100M');
return ($recomended_size <= $max_size);
}
//upload_max_filesize = 100M
function check_upload_max_filesize() {
$max_size = parse_size(ini_get('upload_max_filesize'));
$recomended_size = parse_size('100M');
return ($recomended_size <= $max_size);
}
//memory_limit = 100M
function check_memory_limit() {
$max_size = parse_size(ini_get('memory_limit'));
$recomended_size = parse_size('512M');
return ($recomended_size <= $max_size);
}
function check_mysqlnd() {
return function_exists('mysqli_fetch_all');
}
function base64DataToImage($imgBase64) {
$img = $imgBase64;
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
return base64_decode($img);
}
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = "127.0.0.1";
}
return $ip;
}
function cleanString($text) {
$utf8 = array(
'/[áàâãªä]/u' => 'a',
'/[ÁÀÂÃÄ]/u' => 'A',
'/[ÍÌÎÏ]/u' => 'I',
'/[íìîï]/u' => 'i',
'/[éèêë]/u' => 'e',
'/[ÉÈÊË]/u' => 'E',
'/[óòôõºö]/u' => 'o',
'/[ÓÒÔÕÖ]/u' => 'O',
'/[úùûü]/u' => 'u',
'/[ÚÙÛÜ]/u' => 'U',
'/ç/' => 'c',
'/Ç/' => 'C',
'/ñ/' => 'n',
'/Ñ/' => 'N',
'/–/' => '-', // UTF-8 hyphen to 'normal' hyphen
'/[’‘‹›‚]/u' => ' ', // Literally a single quote
'/[“”«»„]/u' => ' ', // Double quote
'/ /' => ' ', // nonbreaking space (equiv. to 0x160)
'/Є/' => 'YE', '/І/' => 'I', '/Ѓ/' => 'G', '/і/' => 'i', '/№/' => '#', '/є/' => 'ye', '/ѓ/' => 'g',
'/А/' => 'A', '/Б/' => 'B', '/В/' => 'V', '/Г/' => 'G', '/Д/' => 'D',
'/Е/' => 'E', '/Ё/' => 'YO', '/Ж/' => 'ZH',
'/З/' => 'Z', '/И/' => 'I', '/Й/' => 'J', '/К/' => 'K', '/Л/' => 'L',
'/М/' => 'M', '/Н/' => 'N', '/О/' => 'O', '/П/' => 'P', '/Р/' => 'R',
'/С/' => 'S', '/Т/' => 'T', '/У/' => 'U', '/Ф/' => 'F', '/Х/' => 'H',
'/Ц/' => 'C', '/Ч/' => 'CH', '/Ш/' => 'SH', '/Щ/' => 'SHH', '/Ъ/' => '',
'/Ы/' => 'Y', '/Ь/' => '', '/Э/' => 'E', '/Ю/' => 'YU', '/Я/' => 'YA',
'/а/' => 'a', '/б/' => 'b', '/в/' => 'v', '/г/' => 'g', '/д/' => 'd',
'/е/' => 'e', '/ё/' => 'yo', '/ж/' => 'zh',
'/з/' => 'z', '/и/' => 'i', '/й/' => 'j', '/к/' => 'k', '/л/' => 'l',
'/м/' => 'm', '/н/' => 'n', '/о/' => 'o', '/п/' => 'p', '/р/' => 'r',
'/с/' => 's', '/т/' => 't', '/у/' => 'u', '/ф/' => 'f', '/х/' => 'h',
'/ц/' => 'c', '/ч/' => 'ch', '/ш/' => 'sh', '/щ/' => 'shh', '/ъ/' => '',
'/ы/' => 'y', '/ь/' => '', '/э/' => 'e', '/ю/' => 'yu', '/я/' => 'ya',
'/—/' => '-', '/«/' => '', '/»/' => '', '/…/' => ''
);
return preg_replace(array_keys($utf8), array_values($utf8), $text);
}
function cleanURLName($name) {
$name = preg_replace('/[!#$&\'()*+,\\/:;=?@[\\]%" ]+/', '-', trim(strtolower(cleanString($name))));
return trim(preg_replace('/[\x00-\x1F\x7F]/u', '', $name), "-");
}
/**
* @brief return true if running in CLI, false otherwise
* if is set $_GET['ignoreCommandLineInterface'] will return false
* @return boolean
*/
function isCommandLineInterface() {
return (empty($_GET['ignoreCommandLineInterface']) && php_sapi_name() === 'cli');
}
/**
* @brief show status message as text (CLI) or JSON-encoded array (web)
*
* @param array $statusarray associative array with type/message pairs
* @return string
*/
function status($statusarray) {
if (isCommandLineInterface()) {
foreach ($statusarray as $status => $message) {
echo $status . ":" . $message . "\n";
}
} else {
echo json_encode(array_map(function ($text) {
return nl2br($text);
}, $statusarray));
}
}
/**
* @brief show status message and die
*
* @param array $statusarray associative array with type/message pairs
*/
function croak($statusarray) {
status($statusarray);
die;
}
function getSecondsTotalVideosLength() {
$configFile = dirname(__FILE__) . '/../videos/configuration.php';
require_once $configFile;
global $global;
if (!User::isLogged()) {
return 0;
}
$sql = "SELECT * FROM videos v ";
$formats = "";
$values = array();
if (!User::isAdmin()) {
$id = User::getId();
$sql .= " WHERE users_id = ? ";
$formats = "i";
$values = array($id);
}
$res = sqlDAL::readSql($sql, $formats, $values);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$seconds = 0;
foreach ($fullData as $row) {
$seconds += parseDurationToSeconds($row['duration']);
}
return $seconds;
}
function getMinutesTotalVideosLength() {
$seconds = getSecondsTotalVideosLength();
return floor($seconds / 60);
}
function secondsToVideoTime($seconds) {
if (!is_numeric($seconds)) {
return $seconds;
}
$seconds = round($seconds);
$hours = floor($seconds / 3600);
$mins = floor($seconds / 60 % 60);
$secs = floor($seconds % 60);
return sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
}
function parseSecondsToDuration($seconds) {
return secondsToVideoTime($seconds);
}
function parseDurationToSeconds($str) {
if (is_numeric($str)) {
return intval($str);
}
$durationParts = explode(":", $str);
if (empty($durationParts[1]) || $durationParts[0] == "EE") {
return 0;
}
if (empty($durationParts[2])) {
$durationParts[2] = 0;
}
$minutes = intval(($durationParts[0]) * 60) + intval($durationParts[1]);
return intval($durationParts[2]) + ($minutes * 60);
}
function durationToSeconds($str) {
return parseDurationToSeconds($str);
}
function secondsToDuration($seconds) {
return parseSecondsToDuration($seconds);
}
/**
*
* @global type $global
* @param type $mail
* call it before send mail to let AVideo decide the method
*/
function setSiteSendMessage(&$mail) {
global $global;
if (empty($_POST["comment"])) {
$_POST["comment"] = "";
}
require_once $global['systemRootPath'] . 'objects/configuration.php';
$config = new Configuration();
$mail->CharSet = 'UTF-8';
if ($config->getSmtp()) {
_error_log("Sending SMTP Email");
$mail->CharSet = 'UTF-8';
$mail->IsSMTP(); // enable SMTP
if (!empty($_POST) && $_POST["comment"] == "Teste of comment" && User::isAdmin()) {
$mail->SMTPDebug = 3;
$mail->Debugoutput = function ($str, $level) {
_error_log("SMTP ERROR $level; message: $str", AVideoLog::$ERROR);
};
}
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPAuth = $config->getSmtpAuth(); // authentication enabled
$mail->SMTPSecure = $config->getSmtpSecure(); // secure transfer enabled REQUIRED for Gmail
$mail->Host = $config->getSmtpHost();
$mail->Port = $config->getSmtpPort();
$mail->Username = $config->getSmtpUsername();
$mail->Password = $config->getSmtpPassword();
//_error_log(print_r($config, true));
} else {
_error_log("Sending SendMail Email");
$mail->isSendmail();
}
}
function array_iunique($array) {
return array_intersect_key($array, array_unique(array_map("strtolower", $array)));
}
function partition(array $list, $totalItens) {
$listlen = count($list);
_error_log("partition: listlen={$listlen} totalItens={$totalItens}");
$p = ceil($listlen / $totalItens);
$partlen = floor($listlen / $p);
$partition = array();
$mark = 0;
for ($index = 0; $index < $p; $index++) {
$partition[$index] = array_slice($list, $mark, $totalItens);
$mark += $totalItens;
}
return $partition;
}
function sendSiteEmail($to, $subject, $message) {
global $advancedCustom;
if (empty($to)) {
return false;
}
if (!is_array($to)) {
$to = array($to);
}
if (empty($advancedCustom)) {
$advancedCustom = AVideoPlugin::loadPlugin("CustomizeAdvanced");
}
$subject = UTF8encode($subject);
$message = UTF8encode($message);
$message = createEmailMessageFromTemplate($message);
_error_log("sendSiteEmail [" . count($to) . "] {$subject}");
global $config, $global;
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/PHPMailer.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/SMTP.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/Exception.php';
$contactEmail = $config->getContactEmail();
$webSiteTitle = $config->getWebSiteTitle();
try {
if (!is_array($to)) {
$mail = new PHPMailer\PHPMailer\PHPMailer;
setSiteSendMessage($mail);
$mail->setFrom($contactEmail, $webSiteTitle);
$mail->Subject = $subject . " - " . $webSiteTitle;
$mail->msgHTML($message);
$mail->addAddress($to);
$resp = $mail->send();
if (!$resp) {
_error_log("sendSiteEmail Error Info: {$mail->ErrorInfo}");
} else {
_error_log("sendSiteEmail Success Info: $subject " . json_encode($to));
}
} else {
$size = intval(@$advancedCustom->splitBulkEmailSend);
if (empty($size)) {
$size = 90;
}
$to = array_iunique($to);
$pieces = partition($to, $size);
foreach ($pieces as $piece) {
$mail = new PHPMailer\PHPMailer\PHPMailer;
setSiteSendMessage($mail);
$mail->setFrom($contactEmail, $webSiteTitle);
$mail->Subject = $subject . " - " . $webSiteTitle;
$mail->msgHTML($message);
$count = 0;
foreach ($piece as $value) {
$count++;
_error_log("sendSiteEmail::addBCC [{$count}] {$value}");
$mail->addBCC($value);
}
$resp = $mail->send();
if (!$resp) {
_error_log("sendSiteEmail Error Info: {$mail->ErrorInfo}");
} else {
_error_log("sendSiteEmail Success Info: $subject " . json_encode($to));
}
}
}
//Set the subject line
return $resp;
} catch (phpmailerException $e) {
_error_log($e->errorMessage()); //Pretty error messages from PHPMailer
} catch (Exception $e) {
_error_log($e->getMessage()); //Boring error messages from anything else!
}
}
function createEmailMessageFromTemplate($message) {
//check if the message already have a HTML body
if (preg_match("/html>/i", $message)) {
return $message;
}
global $global, $config;
$text = file_get_contents("{$global['systemRootPath']}view/include/emailTemplate.html");
$siteTitle = $config->getWebSiteTitle();
$logo = " getLogo(true) . "\" alt=\"{$siteTitle}\">";
$words = array($logo, $message, $siteTitle);
$replace = array('{logo}', '{message}', '{siteTitle}');
return str_replace($replace, $words, $text);
}
function sendEmailToSiteOwner($subject, $message) {
global $advancedCustom;
$subject = UTF8encode($subject);
$message = UTF8encode($message);
_error_log("sendEmailToSiteOwner {$subject}");
global $config, $global;
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/PHPMailer.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/SMTP.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/Exception.php';
$contactEmail = $config->getContactEmail();
$webSiteTitle = $config->getWebSiteTitle();
try {
$mail = new PHPMailer\PHPMailer\PHPMailer;
setSiteSendMessage($mail);
$mail->setFrom($contactEmail, $webSiteTitle);
$mail->Subject = $subject . " - " . $webSiteTitle;
$mail->msgHTML($message);
$mail->addAddress($contactEmail);
$resp = $mail->send();
if (!$resp) {
_error_log("sendEmailToSiteOwner Error Info: {$mail->ErrorInfo}");
} else {
_error_log("sendEmailToSiteOwner Success Info: $subject " . json_encode($to));
}
return $resp;
} catch (phpmailerException $e) {
_error_log($e->errorMessage()); //Pretty error messages from PHPMailer
} catch (Exception $e) {
_error_log($e->getMessage()); //Boring error messages from anything else!
}
}
function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $showinfo = 0, $controls = 1, $time = 0, $objectFit = "") {
//_error_log("parseVideos: $videoString");
if (strpos($videoString, 'youtube.com/embed') !== false) {
return $videoString . (parse_url($videoString, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo='
. $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
}
if (strpos($videoString, 'iframe') !== false) {
// retrieve the video url
$anchorRegex = '/src="(.*)?"/isU';
$results = array();
if (preg_match($anchorRegex, $video, $results)) {
$link = trim($results[1]);
}
} else {
// we already have a url
$link = $videoString;
}
if (stripos($link, 'embed') !== false) {
return $link . (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo='
. $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
} elseif (strpos($link, 'youtube.com') !== false) {
preg_match(
'/[\\?\\&]v=([^\\?\\&]+)/',
$link,
$matches
);
//the ID of the YouTube URL: x6qe_kVaBpg
if (empty($matches[1])) {
return $link;
}
$id = $matches[1];
return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo='
. $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
} elseif (strpos($link, 'youtu.be') !== false) {
//https://youtu.be/9XXOBSsPoMU
preg_match(
'/youtu.be\/([a-zA-Z0-9_]+)($|\/)/',
$link,
$matches
);
//the ID of the YouTube URL: x6qe_kVaBpg
$id = $matches[1];
return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo='
. $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
} elseif (strpos($link, 'player.vimeo.com') !== false) {
// works on:
// http://player.vimeo.com/video/37985580?title=0&byline=0&portrait=0
$videoIdRegex = '/player.vimeo.com\/video\/([0-9]+)\??/i';
preg_match($videoIdRegex, $link, $matches);
$id = $matches[1];
return '//player.vimeo.com/video/' . $id;
} elseif (strpos($link, 'vimeo.com/channels') !== false) {
//extract the ID
preg_match(
'/\/\/(www\.)?vimeo.com\/channels\/[a-z0-9-]+\/(\d+)($|\/)/i',
$link,
$matches
);
//the ID of the Vimeo URL: 71673549
$id = $matches[2];
return '//player.vimeo.com/video/' . $id;
} elseif (strpos($link, 'vimeo.com') !== false) {
//extract the ID
preg_match(
'/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/',
$link,
$matches
);
//the ID of the Vimeo URL: 71673549
$id = $matches[2];
return '//player.vimeo.com/video/' . $id;
} elseif (strpos($link, 'dailymotion.com') !== false) {
//extract the ID
preg_match(
'/\/\/(www\.)?dailymotion.com\/video\/([a-zA-Z0-9_]+)($|\/)/',
$link,
$matches
);
//the ID of the Vimeo URL: 71673549
$id = $matches[2];
return '//www.dailymotion.com/embed/video/' . $id;
} elseif (strpos($link, 'metacafe.com') !== false) {
//extract the ID
preg_match(
'/\/\/(www\.)?metacafe.com\/watch\/([a-zA-Z0-9_\/-]+)$/',
$link,
$matches
);
$id = $matches[2];
return '//www.metacafe.com/embed/' . $id;
} elseif (strpos($link, 'vid.me') !== false) {
//extract the ID
preg_match(
'/\/\/(www\.)?vid.me\/([a-zA-Z0-9_-]+)$/',
$link,
$matches
);
$id = $matches[2];
return '//vid.me/e/' . $id;
} elseif (strpos($link, 'rutube.ru') !== false) {
//extract the ID
preg_match('/\/\/(www\.)?rutube.ru\/video\/([a-zA-Z0-9_-]+)\/.*/', $link, $matches);
$id = $matches[2];
return '//rutube.ru/play/embed/' . $id;
} elseif (strpos($link, 'ok.ru') !== false) {
//extract the ID
preg_match('/\/\/(www\.)?ok.ru\/video\/([a-zA-Z0-9_-]+)$/', $link, $matches);
$id = $matches[2];
return '//ok.ru/videoembed/' . $id;
} elseif (strpos($link, 'streamable.com') !== false) {
//extract the ID
preg_match('/\/\/(www\.)?streamable.com\/([a-zA-Z0-9_-]+)$/', $link, $matches);
$id = $matches[2];
return '//streamable.com/s/' . $id;
} elseif (strpos($link, 'twitch.tv/videos') !== false) {
//extract the ID
preg_match('/\/\/(www\.)?twitch.tv\/videos\/([a-zA-Z0-9_-]+)$/', $link, $matches);
if (!empty($matches[2])) {
$id = $matches[2];
return '//player.twitch.tv/?video=' . $id . '#';
}
//extract the ID
preg_match('/\/\/(www\.)?twitch.tv\/[a-zA-Z0-9_-]+\/v\/([a-zA-Z0-9_-]+)$/', $link, $matches);
$id = $matches[2];
return '//player.twitch.tv/?video=' . $id . '#';
} elseif (strpos($link, 'twitch.tv') !== false) {
//extract the ID
preg_match('/\/\/(www\.)?twitch.tv\/([a-zA-Z0-9_-]+)$/', $link, $matches);
$id = $matches[2];
return '//player.twitch.tv/?channel=' . $id . '#';
} elseif (strpos($link, '/evideo/') !== false) {
//extract the ID
preg_match('/(http.+)\/evideo\/([a-zA-Z0-9_-]+)($|\/)/i', $link, $matches);
//the AVideo site
$site = $matches[1];
$id = $matches[2];
return $site . '/evideoEmbed/' . $id . "?autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time";
} elseif (strpos($link, '/video/') !== false) {
//extract the ID
preg_match('/(http.+)\/video\/([a-zA-Z0-9_-]+)($|\/)/i', $link, $matches);
//the AVideo site
if (!empty($matches[1])) {
$site = $matches[1];
$id = $matches[2];
return $site . '/videoEmbeded/' . $id . "?autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time";
} else {
return $link;
}
}
$url = $videoString;
$url_parsed = parse_url($url);
if (empty($url_parsed['query'])) {
return "";
}
$new_qs_parsed = array();
// Grab our first query string
parse_str($url_parsed['query'], $new_qs_parsed);
// Here's the other query string
$other_query_string = 'modestbranding=1&showinfo='
. $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time";
$other_qs_parsed = array();
parse_str($other_query_string, $other_qs_parsed);
// Stitch the two query strings together
$final_query_string_array = array_merge($new_qs_parsed, $other_qs_parsed);
$final_query_string = http_build_query($final_query_string_array);
// Now, our final URL:
$new_url = $url_parsed['scheme']
. '://'
. $url_parsed['host']
. $url_parsed['path']
. '?'
. $final_query_string;
return $new_url;
// return data
}
$canUseCDN = array();
function canUseCDN($videos_id) {
if (empty($videos_id)) {
return false;
}
global $global, $canUseCDN;
if (!isset($canUseCDN[$videos_id])) {
require_once $global['systemRootPath'] . 'plugin/VR360/Objects/VideosVR360.php';
$pvr360 = AVideoPlugin::isEnabledByName('VR360');
// if the VR360 is enabled you can not use the CDN, it fail to load the GL
$isVR360Enabled = VideosVR360::isVR360Enabled($videos_id);
if ($pvr360 && $isVR360Enabled) {
$ret = false;
} else {
$ret = true;
}
//_error_log(json_encode(array('canUseCDN'=>$ret, '$pvr360'=>$pvr360, '$isVR360Enabled'=>$isVR360Enabled, '$videos_id'=>$videos_id)));
$canUseCDN[$videos_id] = $ret;
}
return $canUseCDN[$videos_id];
}
function clearVideosURL($fileName = "") {
global $global;
$path = getCacheDir() . "getVideosURL/";
if (empty($path)) {
rrmdir($path);
} else {
$cacheFilename = "{$path}{$fileName}.cache";
@unlink($cacheFilename);
}
}
function maxLifetime() {
global $maxLifetime;
if (!isset($maxLifetime)) {
$aws_s3 = AVideoPlugin::getObjectDataIfEnabled('AWS_S3');
$bb_b2 = AVideoPlugin::getObjectDataIfEnabled('Blackblaze_B2');
$secure = AVideoPlugin::getObjectDataIfEnabled('SecureVideosDirectory');
$maxLifetime = 0;
if (!empty($aws_s3) && !empty($aws_s3->presignedRequestSecondsTimeout) && (empty($maxLifetime) || $aws_s3->presignedRequestSecondsTimeout < $maxLifetime) ){
$maxLifetime = $aws_s3->presignedRequestSecondsTimeout;
_error_log("maxLifetime: AWS_S3 = {$maxLifetime}");
}
if (!empty($bb_b2) && !empty($aws_s3->presignedRequestSecondsTimeout) && (empty($maxLifetime) || $bb_b2->presignedRequestSecondsTimeout < $maxLifetime)) {
$maxLifetime = $bb_b2->presignedRequestSecondsTimeout;
_error_log("maxLifetime: B2 = {$maxLifetime}");
}
if (!empty($secure) && !empty($aws_s3->tokenTimeOut) && (empty($maxLifetime) || $secure->tokenTimeOut < $maxLifetime)) {
$maxLifetime = $secure->tokenTimeOut;
_error_log("maxLifetime: Secure = {$maxLifetime}");
}
}
return $maxLifetime;
}
$cacheExpirationTime = false;
function cacheExpirationTime() {
if (isBot()) {
return 604800; // 1 week
}
global $cacheExpirationTime;
if (empty($cacheExpirationTime)) {
$obj = AVideoPlugin::getObjectDataIfEnabled('Cache');
$cacheExpirationTime = @$obj->cacheTimeInSeconds;
}
return intval($cacheExpirationTime);
}
/**
* tell if a file should recreate a cache, based on its time and the plugins toke expirations
* @param type $filename
* @return boolean
*/
function recreateCache($filename) {
return (!file_exists($filename) || time() - filemtime($filename) > minimumExpirationTime());
}
function _getImagesURL($fileName, $type) {
global $global;
$files = array();
$source = Video::getSourceFile($fileName, ".jpg");
$file = $source['path'];
if (file_exists($file)) {
$files["jpg"] = array(
'filename' => "{$fileName}.jpg",
'path' => $file,
'url' => $source['url'],
'type' => 'image',
);
} else {
$files["jpg"] = array(
'filename' => "{$type}.png",
'path' => "{$global['systemRootPath']}view/img/{$type}.png",
'url' => "{$global['webSiteRootURL']}view/img/{$type}.png",
'type' => 'image',
);
}
$source = Video::getSourceFile($fileName, "_portrait.jpg");
$file = $source['path'];
if (file_exists($file)) {
$files["pjpg"] = array(
'filename' => "{$fileName}_portrait.jpg",
'path' => $file,
'url' => $source['url'],
'type' => 'image',
);
} elseif ($type != 'image') {
$files["pjpg"] = array(
'filename' => "{$type}_portrait.png",
'path' => "{$global['systemRootPath']}view/img/{$type}_portrait.png",
'url' => "{$global['webSiteRootURL']}view/img/{$type}_portrait.png",
'type' => 'image',
);
}
return $files;
}
function getVideosURLPDF($fileName) {
global $global;
if (empty($fileName)) {
return array();
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
$source = Video::getSourceFile($fileName, ".pdf");
$file = $source['path'];
$files["pdf"] = array(
'filename' => "{$fileName}.pdf",
'path' => $file,
'url' => $source['url'],
'type' => 'pdf',
);
$files = array_merge($files, _getImagesURL($fileName, 'pdf'));
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
//_error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName ");
return $files;
}
function getVideosURLIMAGE($fileName) {
global $global;
if (empty($fileName)) {
return array();
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
$types = array('png', 'gif', 'webp', 'jpg');
foreach ($types as $value) {
$source = Video::getSourceFile($fileName, ".{$value}");
$file = $source['path'];
$files["image"] = array(
'filename' => "{$fileName}.{$value}",
'path' => $file,
'url' => $source['url'],
'type' => 'image',
);
if (file_exists($file)) {
break;
}
}
$files = array_merge($files, _getImagesURL($fileName, 'image'));
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
//_error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName ");
return $files;
}
function getVideosURLZIP($fileName) {
global $global;
if (empty($fileName)) {
return array();
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
$types = array('zip');
foreach ($types as $value) {
$source = Video::getSourceFile($fileName, ".{$value}");
$file = $source['path'];
$files["zip"] = array(
'filename' => "{$fileName}.zip",
'path' => $file,
'url' => $source['url'],
'type' => 'zip',
);
if (file_exists($file)) {
break;
}
}
$files = array_merge($files, _getImagesURL($fileName, 'zip'));
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
//_error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName ");
return $files;
}
function getVideosURLArticle($fileName) {
global $global;
if (empty($fileName)) {
return array();
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
//$files = array_merge($files, _getImagesURL($fileName, 'article'));
$files = _getImagesURL($fileName, 'article');
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
//_error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName ");
return $files;
}
function getVideosURLAudio($fileName) {
global $global;
if (empty($fileName)) {
return array();
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
$source = Video::getSourceFile($fileName, ".mp3");
$file = $source['path'];
$files["mp3"] = array(
'filename' => "{$fileName}.mp3",
'path' => $file,
'url' => $source['url'],
'type' => 'audio',
);
$files = array_merge($files, _getImagesURL($fileName, 'audio_wave'));
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
//_error_log("getVideosURLAudio generated in {$total_time} seconds. fileName: $fileName ");
return $files;
}
function getVideosURL($fileName, $cache = true) {
return getVideosURL_V2($fileName); // disable this function soon
}
function getVideosURLMP4Only($fileName) {
$allFiles = getVideosURL_V2($fileName);
if (is_array($allFiles)) {
foreach ($allFiles as $key => $value) {
if ($value['format'] !== 'mp4') {
unset($allFiles[$key]);
}
}
return $allFiles;
}
_error_log("getVideosURLMP4Only does not return an ARRAY from getVideosURL_V2($fileName) " . json_encode($allFiles));
return array();
}
function getVideosURLWEBMOnly($fileName) {
$allFiles = getVideosURL_V2($fileName); // disable this function soon
if (is_array($allFiles)) {
foreach ($allFiles as $key => $value) {
if ($value['format'] !== 'webm') {
unset($allFiles[$key]);
}
}
return $allFiles;
}
_error_log("getVideosURLMP4Only does not return an ARRAY from getVideosURL_V2($fileName) " . json_encode($allFiles));
return array();
}
function getVideosURLMP4WEBMOnly($fileName) {
return array_merge(getVideosURLMP4Only($fileName), getVideosURLWEBMOnly($fileName));
}
function getVideosURLOnly($fileName) {
$allFiles = getVideosURL_V2($fileName); // disable this function soon
foreach ($allFiles as $key => $value) {
if ($value['type'] !== 'video') {
unset($allFiles[$key]);
}
}
return $allFiles;
}
$getVideosURL_V2Array = array();
function getVideosURL_V2($fileName, $recreateCache = false) {
global $global, $getVideosURL_V2Array;
if (empty($fileName)) {
return array();
}
//$recreateCache = true;
$cleanfilename = Video::getCleanFilenameFromFile($fileName);
if (!empty($getVideosURL_V2Array[$cleanfilename])) {
return $getVideosURL_V2Array[$cleanfilename];
}
$pdf = "{$global['systemRootPath']}videos/{$cleanfilename}.pdf";
$mp3 = "{$global['systemRootPath']}videos/{$cleanfilename}.mp3";
if (file_exists($pdf)) {
return getVideosURLPDF($fileName);
} elseif (file_exists($mp3)) {
return getVideosURLAudio($fileName);
}
$cacheName = "getVideosURL_V2$fileName";
if (empty($recreateCache)) {
$lifetime = maxLifetime();
$TimeLog1 = "getVideosURL_V2($fileName) empty recreateCache";
TimeLogStart($TimeLog1);
$files = object_to_array(ObjectYPT::getCache($cacheName, $lifetime, true));
if (is_array($files)) {
//_error_log("getVideosURL_V2: do NOT recreate lifetime = {$lifetime}");
$preg_match_url = addcslashes($global['webSiteRootURL'], "/") . "videos";
foreach ($files as $value) {
// check if is a dummy file and the URL still wrong
if (
$value['type'] === 'video' && // is a video
preg_match("/^{$preg_match_url}/", $value['url']) && // the URL is the same as the main domain
filesize($value['path']) < 20) { // file size is small
_error_log("getVideosURL_V2:: dummy file found, fix cache " . json_encode(array("/^{$preg_match_url}/", $value['url'], preg_match("/^{$preg_match_url}video/", $value['url']), filesize($value['path']), $value)));
unset($files);
break;
} else {
//_error_log("getVideosURL_V2:: NOT dummy file ". json_encode(array("/^{$preg_match_url}video/", $value['url'], preg_match("/^{$preg_match_url}video/", $value['url']),filesize($value['path']),$value)));
}
}
//_error_log("getVideosURL_V2:: cachestill good ". json_encode($files));
} else {
//_error_log("getVideosURL_V2:: cache not found ". json_encode($files));
}
TimeLogEnd($TimeLog1, __LINE__);
} else {
_error_log("getVideosURL_V2($fileName) Recreate cache requested " . json_encode(debug_backtrace()));
}
if (empty($files)) {
$files = array();
$plugin = AVideoPlugin::loadPlugin("VideoHLS");
if (!empty($plugin)) {
$files = VideoHLS::getSourceFile($fileName);
}
$video = array('webm', 'mp4');
$audio = array('mp3', 'ogg');
$image = array('jpg', 'gif', 'webp');
$formats = array_merge($video, $audio, $image);
//$globQuery = "{$global['systemRootPath']}videos/{$cleanfilename}*.{" . implode(",", $formats) . "}";
//$filesInDir = glob($globQuery, GLOB_BRACE);
$filesInDir = globVideosDir($cleanfilename, true);
foreach ($filesInDir as $file) {
$parts = pathinfo($file);
$source = Video::getSourceFile($parts['filename'], ".{$parts['extension']}");
if (empty($source)) {
continue;
}
if (filesize($file) < 20000 && !preg_match("/Dummy File/i", file_get_contents($file))) {
continue;
}
if (preg_match("/{$cleanfilename}(_.+)[.]{$parts['extension']}$/", $file, $matches)) {
$resolution = $matches[1];
} else {
preg_match('/_([^_]{0,4}).' . $parts['extension'] . '$/', $file, $matches);
$resolution = @$matches[1];
}
$type = 'video';
if (in_array($parts['extension'], $video)) {
$type = 'video';
} elseif (in_array($parts['extension'], $audio)) {
$type = 'audio';
} elseif (in_array($parts['extension'], $image)) {
$type = 'image';
}
$files["{$parts['extension']}{$resolution}"] = array(
'filename' => "{$parts['filename']}.{$parts['extension']}",
'path' => $file,
'url' => $source['url'],
'type' => $type,
'format' => strtolower($parts['extension']),
);
}
ObjectYPT::setCache($cacheName, $files);
}
$getVideosURL_V2Array[$cleanfilename] = $files;
return $getVideosURL_V2Array[$cleanfilename];
}
function getSources($fileName, $returnArray = false, $try = 0) {
if ($returnArray) {
$videoSources = $audioTracks = $subtitleTracks = array();
} else {
$videoSources = $audioTracks = $subtitleTracks = "";
}
$video = Video::getVideoFromFileNameLight($fileName);
if ($video['type'] !== 'audio' && function_exists('getVRSSources')) {
$videoSources = getVRSSources($fileName, $returnArray);
} else {
//$files = getVideosURL($fileName);
$files = getVideosURL_V2($fileName, !empty($try));
$sources = "";
$sourcesArray = array();
foreach ($files as $key => $value) {
$path_parts = pathinfo($value['path']);
if ($path_parts['extension'] == "webm" || $path_parts['extension'] == "mp4" || $path_parts['extension'] == "m3u8" || $path_parts['extension'] == "mp3" || $path_parts['extension'] == "ogg") {
$obj = new stdClass();
$obj->type = mime_content_type_per_filename($value['path']);
$sources .= "type}\">";
$obj->src = $value['url'];
$sourcesArray[] = $obj;
}
}
$videoSources = $returnArray ? $sourcesArray : $sources;
}
if (function_exists('getVTTTracks')) {
$subtitleTracks = getVTTTracks($fileName, $returnArray);
}
if ($returnArray) {
$return = array_merge($videoSources, $audioTracks, $subtitleTracks);
} else {
$return = $videoSources . $audioTracks . $subtitleTracks;
}
$obj = new stdClass();
$obj->result = $return;
if (empty($videoSources) && empty($audioTracks) && !empty($video['id']) && $video['type'] == 'video') {
if (empty($try)) {
//sleep(1);
$sources = getSources($fileName, $returnArray, $try + 1);
if (!empty($sources)) {
Video::updateFilesize($video['id']);
}
Video::clearCache($video['id']);
return $sources;
} else {
_error_log("getSources($fileName) File not found " . json_encode($video));
$obj = new stdClass();
$obj->type = "video/mp4";
$obj->src = "Video not found";
$obj->label = "Video not found";
$obj->res = 0;
$sourcesArray["mp4"] = $obj;
$sources["mp4"] = "type}\" label=\"{$obj->label}\" res=\"{$obj->res}\">";
$return = $returnArray ? $sourcesArray : implode(PHP_EOL, $sources);
}
}
return $return;
}
/**
*
* @param type $file_src
* @return typeget image size with cache
*/
function getimgsize($file_src) {
global $_getimagesize;
if (empty($_getimagesize)) {
$_getimagesize = array();
}
$name = "getimgsize_" . md5($file_src);
if (!empty($_getimagesize[$name])) {
$size = $_getimagesize[$name];
} else {
$cached = ObjectYPT::getCache($name, 86400); //one day
if (!empty($cached)) {
$c = (Array) $cached;
$size = array();
foreach ($c as $key => $value) {
if (preg_match("/^[0-9]+$/", $key)) {
$key = intval($key);
}
$size[$key] = $value;
}
$_getimagesize[$name] = $size;
return $size;
}
$size = @getimagesize($file_src);
if (empty($size)) {
$size = array(1024, 768);
}
ObjectYPT::setCache($name, $size);
$_getimagesize[$name] = $size;
}
return $size;
}
function im_resize($file_src, $file_dest, $wd, $hd, $q = 80) {
if (empty($file_dest)) {
return false;
}
if (!file_exists($file_src)) {
_error_log("im_resize: Source not found: {$file_src}");
return false;
}
$size = getimgsize($file_src);
if ($size === false) {
_error_log("im_resize: Could not get image size: {$file_src}");
return false;
}
if (empty($size['mime']) || $size['mime'] == 'image/pjpeg') {
$size['mime'] = 'image/jpeg';
}
$format = strtolower(substr($size['mime'], strpos($size['mime'], '/') + 1));
if (empty($format)) {
$format = 'jpeg';
}
$destformat = strtolower(substr($file_dest, -4));
if (empty($destformat)) {
_error_log("destformat not found {$file_dest}");
$destformat = ".jpg";
}
$icfunc = "imagecreatefrom" . $format;
if (!function_exists($icfunc)) {
_error_log("im_resize: Function does not exists: {$icfunc}");
return false;
}
$imgSize = getimagesize($file_src);
if (empty($imgSize)) {
_error_log("im_resize: getimagesize($file_src) return false " . json_encode($imgSize));
return false;
}
try {
$src = $icfunc($file_src);
} catch (Exception $exc) {
_error_log("im_resize: " . $exc->getMessage());
_error_log("im_resize: Try {$icfunc} from string");
$src = imagecreatefromstring(file_get_contents($file_src));
if (!$src) {
_error_log("im_resize: fail {$icfunc} from string");
return false;
}
}
$ws = imagesx($src);
$hs = imagesy($src);
if ($ws <= $hs) {
$hd = ceil(($wd * $hs) / $ws);
} else {
$wd = ceil(($hd * $ws) / $hs);
}
if ($ws <= $wd) {
$wd = $ws;
$hd = $hs;
}
$wc = ($wd * $hs) / $hd;
if ($wc <= $ws) {
$hc = ($wc * $hd) / $wd;
} else {
$hc = ($ws * $hd) / $wd;
$wc = ($wd * $hc) / $hd;
}
$dest = imagecreatetruecolor($wd, $hd);
switch ($format) {
case "png":
imagealphablending($dest, false);
imagesavealpha($dest, true);
$transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127);
imagefilledrectangle($dest, 0, 0, $wd, $hd, $transparent);
break;
case "gif":
// integer representation of the color black (rgb: 0,0,0)
$background = imagecolorallocate($src, 0, 0, 0);
// removing the black from the placeholder
imagecolortransparent($src, $background);
break;
}
imagecopyresampled($dest, $src, 0, 0, ($ws - $wc) / 2, ($hs - $hc) / 2, $wd, $hd, $wc, $hc);
$saved = false;
if ($destformat == '.png') {
$saved = imagepng($dest, $file_dest);
}
if ($destformat == '.jpg') {
$saved = imagejpeg($dest, $file_dest, $q);
}
if (!$saved) {
_error_log('saving failed');
}
imagedestroy($dest);
imagedestroy($src);
@chmod($file_dest, 0666);
return true;
}
function im_resizeV2($file_src, $file_dest, $wd, $hd, $q = 80) {
_error_log("im_resizeV2: $file_src, $file_dest, $wd, $hd, $q");
$newImage = im_resize($file_src, $file_dest, $wd, $hd, 100);
if (!$newImage) {
return false;
}
$src = imagecreatefromjpeg($file_dest);
$ws = imagesx($src);
$hs = imagesy($src);
if ($ws < $wd) {
$dst_x = ($wd - $ws) / 2;
} else {
$dst_x = 0;
}
if ($hs < $hd) {
$dst_y = ($hd - $hs) / 2;
} else {
$dst_y = 0;
}
$mapImage = imagecreatetruecolor($wd, $hd);
$bgColor = imagecolorallocate($mapImage, 0, 0, 0);
imagefill($mapImage, 0, 0, $bgColor);
$tileImg = imagecreatefromjpeg($file_dest);
imagecopy($mapImage, $tileImg, $dst_x, $dst_y, 0, 0, $ws, $hs);
$saved = imagejpeg($mapImage, $file_dest, $q);
return $saved;
}
function im_resizeV3($file_src, $file_dest, $wd, $hd) {
_error_log("im_resizeV3: $file_src, $file_dest, $wd, $hd");
// This tries to preserve the aspect ratio of the thumb while letterboxing it in
// The same way that the encoder now does.
eval('$ffmpeg ="ffmpeg -i {$file_src} -filter_complex \"scale=(iw*sar)*min({$wd}/(iw*sar)\,{$hd}/ih):ih*min({$wd}/(iw*sar)\,{$hd}/ih), pad={$wd}:{$hd}:({$wd}-iw*min({$wd}/iw\,{$hd}/ih))/2:({$hd}-ih*min({$wd}/iw\,{$hd}/ih))/2\" -sws_flags lanczos -qscale:v 2 {$file_dest}";');
exec($ffmpeg . " < /dev/null 2>&1", $output, $return_val);
}
function im_resize_max_size($file_src, $file_dest, $max_width, $max_height) {
$fn = $file_src;
$tmpFile = getTmpFile() . ".jpg";
if (empty($fn)) {
_error_log("im_resize_max_size: file name is empty, Destination: {$file_dest}", AVideoLog::$ERROR);
return false;
}
if (function_exists("exif_read_data")) {
error_log($fn);
convertImage($fn, $tmpFile, 100);
$exif = exif_read_data($tmpFile);
if ($exif && isset($exif['Orientation'])) {
$orientation = $exif['Orientation'];
if ($orientation != 1) {
$img = imagecreatefromjpeg($tmpFile);
$deg = 0;
switch ($orientation) {
case 3:
$deg = 180;
break;
case 6:
$deg = 270;
break;
case 8:
$deg = 90;
break;
}
if ($deg) {
$img = imagerotate($img, $deg, 0);
}
imagejpeg($img, $fn, 100);
}
}
} else {
_error_log("Make sure you install the php_mbstring and php_exif to be able to rotate images");
}
$size = getimagesize($fn);
$ratio = $size[0] / $size[1]; // width/height
if ($size[0] <= $max_width && $size[1] <= $max_height) {
$width = $size[0];
$height = $size[1];
} elseif ($ratio > 1) {
$width = $max_width;
$height = $max_height / $ratio;
} else {
$width = $max_width * $ratio;
$height = $max_height;
}
$src = imagecreatefromstring(file_get_contents($fn));
$dst = imagecreatetruecolor($width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagedestroy($src);
imagejpeg($dst, $file_dest); // adjust format as needed
imagedestroy($dst);
@unlink($file_src);
@unlink($tmpFile);
}
function convertImage($originalImage, $outputImage, $quality) {
$imagetype = 0;
if (function_exists('exif_imagetype')) {
$imagetype = exif_imagetype($originalImage);
}
// jpg, png, gif or bmp?
$exploded = explode('.', $originalImage);
$ext = $exploded[count($exploded) - 1];
try {
if ($imagetype == IMAGETYPE_JPEG || preg_match('/jpg|jpeg/i', $ext)) {
$imageTmp = @imagecreatefromjpeg($originalImage);
} elseif ($imagetype == IMAGETYPE_PNG || preg_match('/png/i', $ext)) {
$imageTmp = imagecreatefrompng($originalImage);
} elseif ($imagetype == IMAGETYPE_GIF || preg_match('/gif/i', $ext)) {
$imageTmp = imagecreatefromgif($originalImage);
} elseif ($imagetype == IMAGETYPE_BMP || preg_match('/bmp/i', $ext)) {
$imageTmp = imagecreatefrombmp($originalImage);
} elseif ($imagetype == IMAGETYPE_WEBP || preg_match('/webp/i', $ext)) {
$imageTmp = imagecreatefromwebp($originalImage);
} else {
_error_log("convertImage: File Extension not found ($originalImage, $outputImage, $quality) " . exif_imagetype($originalImage));
return 0;
}
} catch (Exception $exc) {
_error_log("convertImage: " . $exc->getMessage());
return 0;
}
if (!is_resource($imageTmp)) {
_error_log("convertImage: could not create a resource $originalImage, $outputImage, $quality");
return 0;
}
// quality is a value from 0 (worst) to 100 (best)
imagejpeg($imageTmp, $outputImage, $quality);
imagedestroy($imageTmp);
return 1;
}
function decideMoveUploadedToVideos($tmp_name, $filename, $type = "video") {
global $global;
$obj = new stdClass();
$aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
$ftp = AVideoPlugin::loadPluginIfEnabled('FTP_Storage');
$destinationFile = "{$global['systemRootPath']}videos/{$filename}";
_error_log("decideMoveUploadedToVideos: {$filename}");
$path_info = pathinfo($filename);
if ($type !== "zip" && $path_info['extension'] === 'zip') {
_error_log("decideMoveUploadedToVideos: ZIp file {$filename}");
$dir = "{$global['systemRootPath']}videos/{$path_info['filename']}";
unzipDirectory($tmp_name, $dir); // unzip it
cleanDirectory($dir);
if (!empty($aws_s3)) {
//$aws_s3->move_uploaded_file($tmp_name, $filename);
} elseif (!empty($bb_b2)) {
$bb_b2->move_uploaded_directory($dir);
} elseif (!empty($ftp)) {
//$ftp->move_uploaded_file($tmp_name, $filename);
}
} else {
_error_log("decideMoveUploadedToVideos: NOT ZIp file {$filename}");
if (!empty($aws_s3)) {
_error_log("decideMoveUploadedToVideos: S3 {$filename}");
$aws_s3->move_uploaded_file($tmp_name, $filename);
} elseif (!empty($bb_b2)) {
_error_log("decideMoveUploadedToVideos: B2 {$filename}");
$bb_b2->move_uploaded_file($tmp_name, $filename);
} elseif (!empty($ftp)) {
_error_log("decideMoveUploadedToVideos: FTP {$filename}");
$ftp->move_uploaded_file($tmp_name, $filename);
} else {
_error_log("decideMoveUploadedToVideos: Local {$filename}");
if (!move_uploaded_file($tmp_name, $destinationFile)) {
if (!rename($tmp_name, $destinationFile)) {
if (!copy($tmp_name, $destinationFile)) {
$obj->msg = "Error on decideMoveUploadedToVideos({$tmp_name}, $destinationFile)";
die(json_encode($obj));
}
}
}
chmod($destinationFile, 0644);
}
}
sleep(1);
$fsize = @filesize($destinationFile);
_error_log("decideMoveUploadedToVideos: destinationFile {$destinationFile} filesize=" . ($fsize) . " (" . humanFileSize($fsize) . ")");
Video::clearCacheFromFilename($filename);
}
function unzipDirectory($filename, $destination) {
global $global;
// Wait a couple of seconds to make sure the file has completed transfer
sleep(2);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 7200); // 2 hours
$cmd = "unzip {$filename} -d {$destination}" . " 2>&1";
_error_log("unzipDirectory: {$cmd}");
exec($cmd, $output, $return_val);
if ($return_val !== 0 && function_exists("zip_open")) {
// try to unzip using PHP
_error_log("unzipDirectory: TRY to use PHP {$filename}");
$zip = zip_open($filename);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$path = "{$destination}/" . zip_entry_name($zip_entry);
_error_log("unzipDirectory: fopen $path");
if (substr(zip_entry_name($zip_entry), -1) == '/') {
make_path($path);
} else {
make_path($path);
$fp = fopen($path, "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, "$buf");
zip_entry_close($zip_entry);
fclose($fp);
}
}
}
zip_close($zip);
} else {
_error_log("unzipDirectory: ERROR php zip does not work");
}
} else {
_error_log("unzipDirectory: Success {$destination}");
}
@unlink($filename);
}
function make_path($path) {
if (substr($path, -1) !== '/') {
$path = pathinfo($path, PATHINFO_DIRNAME);
}
if (!is_dir($path)) {
@mkdir($path, 0755, true);
}
}
/**
* for security clean all non secure files from directory
* @param type $dir
* @param type $allowedExtensions
* @return type
*/
function cleanDirectory($dir, $allowedExtensions = array('key', 'm3u8', 'ts', 'vtt', 'jpg', 'gif', 'mp3', 'webm')) {
$ffs = scandir($dir);
unset($ffs[array_search('.', $ffs, true)]);
unset($ffs[array_search('..', $ffs, true)]);
// prevent empty ordered elements
if (count($ffs) < 1) {
return;
}
foreach ($ffs as $ff) {
$current = $dir . '/' . $ff;
if (is_dir($current)) {
cleanDirectory($current, $allowedExtensions);
}
$path_parts = pathinfo($current);
if (!empty($path_parts['extension']) && !in_array($path_parts['extension'], $allowedExtensions)) {
unlink($current);
}
}
}
function decideFile_put_contentsToVideos($tmp_name, $filename) {
global $global;
$aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
$ftp = AVideoPlugin::loadPluginIfEnabled('FTP_Storage');
if (!empty($bb_b2)) {
$bb_b2->move_uploaded_file($tmp_name, $filename);
} elseif (!empty($aws_s3)) {
$aws_s3->move_uploaded_file($tmp_name, $filename);
} elseif (!empty($ftp)) {
$ftp->move_uploaded_file($tmp_name, $filename);
} else {
if (!move_uploaded_file($tmp_name, "{$global['systemRootPath']}videos/{$filename}")) {
$obj->msg = "Error on move_uploaded_file({$tmp_name}, {$global['systemRootPath']}videos/{$filename})";
die(json_encode($obj));
}
}
}
if (!function_exists('mime_content_type')) {
function mime_content_type($filename)
{
return mime_content_type_per_filename($filename);
}
}
function fontAwesomeClassName($filename) {
$mime_type = mime_content_type_per_filename($filename);
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = array(
// Media
'image' => 'fas fa-file-image',
'audio' => 'fas fa-file-audio',
'video' => 'fas fa-file-video',
// Documents
'application/pdf' => 'fas fa-file-pdf',
'application/msword' => 'fas fa-file-word',
'application/vnd.ms-word' => 'fas fa-file-word',
'application/vnd.oasis.opendocument.text' => 'fas fa-file-word',
'application/vnd.openxmlformats-officedocument.wordprocessingml' => 'fas fa-file-word',
'application/vnd.ms-excel' => 'fas fa-file-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml' => 'fas fa-file-excel',
'application/vnd.oasis.opendocument.spreadsheet' => 'fas fa-file-excel',
'application/vnd.ms-powerpoint' => 'fas fa-file-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml' => 'fas fa-file-powerpoint',
'application/vnd.oasis.opendocument.presentation' => 'fas fa-file-powerpoint',
'text/plain' => 'far fa-file-alt',
'text/html' => 'fas fa-code',
'application/json' => 'fas fa-code',
// Archives
'application/gzip' => 'far fa-file-archive',
'application/zip' => 'far fa-file-archive',
);
foreach ($icon_classes as $text => $icon) {
if (strpos($mime_type, $text) === 0) {
return $icon;
}
}
return 'fas fa-file';
}
function mime_content_type_per_filename($filename) {
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'mp4' => 'video/mp4',
'avi' => 'video/avi',
'mkv' => 'video/mkv',
'wav' => 'audio/wav',
'm4v' => 'video/mpeg',
'webm' => 'video/webm',
'wmv' => 'video/wmv',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'f4v' => 'video/x-flv',
'm4v' => 'video/m4v',
'm4a' => 'video/quicktime',
'm2p' => 'video/quicktime',
'rm' => 'video/quicktime',
'vob' => 'video/quicktime',
'mkv' => 'video/quicktime',
'3gp' => 'video/quicktime',
'm3u8' => 'application/x-mpegURL',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet'
);
if (filter_var($filename, FILTER_VALIDATE_URL) === false) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
} else {
$ext = pathinfo(parse_url($filename, PHP_URL_PATH), PATHINFO_EXTENSION);
}
if ($ext === 'mp4' || $ext === 'webm') {
$securePlugin = AVideoPlugin::loadPluginIfEnabled('SecureVideosDirectory');
if (!empty($securePlugin)) {
if (method_exists($securePlugin, "useEncoderWatrermarkFromFileName") && $securePlugin->useEncoderWatrermarkFromFileName($filename)) {
return "application/x-mpegURL";
}
}
}
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
} else {
return 'application/octet-stream';
}
}
function combineFiles($filesArray, $extension = "js") {
global $global, $advancedCustom;
$cacheDir = $global['systemRootPath'] . 'videos/cache/' . $extension . "/";
if (!is_dir($cacheDir)) {
mkdir($cacheDir, 0777, true);
}
$str = "";
$fileName = "";
foreach ($filesArray as $value) {
$fileName .= $value;
}
if ($advancedCustom != false) {
$minifyEnabled = $advancedCustom->EnableMinifyJS;
} else {
$minifyEnabled = false;
}
// temporary disable minify
$minifyEnabled = false;
$md5FileName = md5($fileName) . ".{$extension}";
if (!file_exists($cacheDir . $md5FileName)) {
foreach ($filesArray as $value) {
if (file_exists($global['systemRootPath'] . $value)) {
$str .= "\n/*{$value} created local with systemRootPath */\n" . local_get_contents($global['systemRootPath'] . $value);
} elseif (file_exists($value)) {
$str .= "\n/*{$value} created local with full-path given */\n" . local_get_contents($value);
} else {
$allowed = "";
if (ini_get('allow_url_fopen')) {
$allowed .= "allow_url_fopen is on and ";
}
if (function_exists('curl_init')) {
$allowed .= "curl is on";
} else {
$allowed .= "curl is off";
}
$content = url_get_contents($value);
if (empty($content)) {
$allowed .= " - web-fallback 1 (add webSiteRootURL)";
$content = url_get_contents($global['webSiteRootURL'] . $value);
}
$str .= "\n/*{$value} created via web with own url ({$allowed}) */\n" . $content;
}
}
//if ((($extension == "js" || $extension == "css") && ($minifyEnabled))) {
if ($extension == "css" && ($minifyEnabled)) {
require_once $global['systemRootPath'] . 'objects/jshrink.php';
$str = \JShrink\Minifier::minify($str, array('flaggedComments' => false));
}
file_put_contents($cacheDir . $md5FileName, $str);
}
return $global['webSiteRootURL'] . 'videos/cache/' . $extension . "/" . $md5FileName . "?" . filectime($cacheDir . $md5FileName);
}
function local_get_contents($path) {
if (function_exists('fopen')) {
$myfile = fopen($path, "r") or die("Unable to open file!");
$text = fread($myfile, filesize($path));
fclose($myfile);
return $text;
}
}
function getSelfUserAgent() {
global $global, $AVideoStreamer_UA;
$agent = $AVideoStreamer_UA . " ";
$agent .= parse_url($global['webSiteRootURL'], PHP_URL_HOST);
return $agent;
}
function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false) {
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort;
if ($debug) {
_error_log("url_get_contents: Start $url, $ctx, $timeout");
}
$agent = getSelfUserAgent();
if (empty($ctx)) {
$opts = array(
'http' => array('header' => "User-Agent: {$agent}\r\n"),
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
"allow_self_signed" => true,
),
);
if (!empty($timeout)) {
ini_set('default_socket_timeout', $timeout);
$opts['http'] = array('timeout' => $timeout);
}
$context = stream_context_create($opts);
} else {
$context = $ctx;
}
if (ini_get('allow_url_fopen')) {
if ($debug) {
_error_log("url_get_contents: allow_url_fopen {$url}");
}
try {
$tmp = @file_get_contents($url, false, $context);
if ($tmp != false) {
if ($debug) {
_error_log("url_get_contents: SUCCESS file_get_contents($url) ");
}
return remove_utf8_bom($tmp);
}
if ($debug) {
_error_log("url_get_contents: ERROR file_get_contents($url) ");
}
} catch (ErrorException $e) {
if ($debug) {
_error_log("url_get_contents: allow_url_fopen ERROR " . $e->getMessage() . " {$url}");
}
return "url_get_contents: " . $e->getMessage();
}
} elseif (function_exists('curl_init')) {
if ($debug) {
_error_log("url_get_contents: CURL {$url} ");
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if (!empty($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout + 10);
}
$output = curl_exec($ch);
curl_close($ch);
if ($debug) {
_error_log("url_get_contents: CURL SUCCESS {$url}");
}
return remove_utf8_bom($output);
}
if ($debug) {
_error_log("url_get_contents: Nothing yet {$url}");
}
// try wget
$filename = getTmpDir("YPTurl_get_contents") . md5($url);
if ($debug) {
_error_log("url_get_contents: try wget $filename {$url}");
}
if (wget($url, $filename, $debug)) {
if ($debug) {
_error_log("url_get_contents: wget success {$url} ");
}
$result = file_get_contents($filename);
unlink($filename);
if (!empty($result)) {
return remove_utf8_bom($result);
}
} elseif ($debug) {
_error_log("url_get_contents: try wget fail {$url}");
}
$result = @file_get_contents($url, false, $context);
if ($debug) {
_error_log("url_get_contents: Last try {$url}");
}
return remove_utf8_bom($result);
}
function getUpdatesFilesArray() {
global $config, $global;
if (!class_exists('User') || !User::isAdmin()) {
return array();
}
$files1 = scandir($global['systemRootPath'] . "updatedb");
$updateFiles = array();
foreach ($files1 as $value) {
preg_match("/updateDb.v([0-9.]*).sql/", $value, $match);
if (!empty($match)) {
if ($config->currentVersionLowerThen($match[1])) {
$updateFiles[] = array('filename' => $match[0], 'version' => $match[1]);
}
}
}
return $updateFiles;
}
function thereIsAnyUpdate() {
if (!User::isAdmin()) {
return false;
}
$name = 'thereIsAnyUpdate';
if (!isset($_SESSION['user'][$name])) {
_session_start();
$_SESSION['user'][$name] = !empty(getUpdatesFilesArray());
}
return $_SESSION['user'][$name];
}
function thereIsAnyRemoteUpdate() {
if (!User::isAdmin()) {
return false;
}
global $config;
$version = json_decode(url_get_contents("https://tutorials.avideo.com/version"));
$name = 'thereIsAnyRemoteUpdate';
if (!isset($_SESSION['user'][$name])) {
if (!empty($version)) {
_session_start();
if (version_compare($config->getVersion(), $version->version) === -1) {
$_SESSION['user'][$name] = $version;
} else {
$_SESSION['user'][$name] = false;
}
}
}
return $_SESSION['user'][$name];
}
function UTF8encode($data) {
global $advancedCustom, $global;
if (!empty($advancedCustom->utf8Encode)) {
return utf8_encode($data);
}
if (!empty($advancedCustom->utf8Decode)) {
return utf8_decode($data);
}
return $data;
}
//detect search engine bots
function isBot() {
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return true;
}
if (isAVideoEncoder()) {
return false;
}
// User lowercase string for comparison.
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
// A list of some common words used only for bots and crawlers.
$bot_identifiers = array(
'bot',
'slurp',
'crawler',
'spider',
'curl',
'facebook',
'fetch',
'loader',
);
// See if one of the identifiers is in the UA string.
foreach ($bot_identifiers as $identifier) {
if (strpos($user_agent, $identifier) !== false) {
return true;
}
}
return false;
}
/**
* A function that could get me the last N lines of a log file.
* @param type $filepath
* @param type $lines
* @param type $adaptive
* @return boolean
*/
function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false) {
if (!function_exists('mb_strlen')) {
$msg = "AVideoLog::ERROR you need to install the mb_strlen function to make it work, please the command 'sudo apt install php-mbstring'";
if ($returnArray) {
return array(array($msg));
} else {
return $msg;
}
}
// Open file
$f = @fopen($filepath, "rb");
if ($f === false) {
return false;
}
// Sets buffer size, according to the number of lines to retrieve.
// This gives a performance boost when reading a few lines from the file.
if (!$adaptive) {
$buffer = 4096;
} else {
$buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096));
}
// Jump to last character
fseek($f, -1, SEEK_END);
// Read it and adjust line number if necessary
// (Otherwise the result would be wrong if file doesn't end with a blank line)
if (fread($f, 1) != "\n") {
$lines -= 1;
}
// Start reading
$output = '';
$chunk = '';
// While we would like more
while (ftell($f) > 0 && $lines >= 0) {
// Figure out how far back we should jump
$seek = min(ftell($f), $buffer);
// Do the jump (backwards, relative to where we are)
fseek($f, -$seek, SEEK_CUR);
// Read a chunk and prepend it to our output
$output = ($chunk = fread($f, $seek)) . $output;
// Jump back to where we started reading
fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
// Decrease our line counter
$lines -= substr_count($chunk, "\n");
}
// While we have too many lines
// (Because of buffer size we might have read too many)
while ($lines++ < 0) {
// Find first newline and remove all text before that
$output = substr($output, strpos($output, "\n") + 1);
}
// Close file and return
fclose($f);
$output = trim($output);
if ($returnArray) {
$array = explode("\n", $output);
$newArray = array();
foreach ($array as $value) {
$newArray[] = array($value);
}
return $newArray;
} else {
return $output;
}
}
function encryptPassword($password, $noSalt = false) {
global $advancedCustom, $global, $advancedCustomUser;
if (!empty($advancedCustomUser->encryptPasswordsWithSalt) && !empty($global['salt']) && empty($noSalt)) {
$password .= $global['salt'];
}
return md5(hash("whirlpool", sha1($password)));
}
function encryptPasswordVerify($password, $hash, $encodedPass = false) {
global $advancedCustom, $global;
if (!$encodedPass || $encodedPass === 'false') {
//_error_log("encryptPasswordVerify: encrypt");
$passwordSalted = encryptPassword($password);
// in case you enable the salt later
$passwordUnSalted = encryptPassword($password, true);
} else {
//_error_log("encryptPasswordVerify: do not encrypt");
$passwordSalted = $password;
// in case you enable the salt later
$passwordUnSalted = $password;
}
//_error_log("passwordSalted = $passwordSalted, hash=$hash, passwordUnSalted=$passwordUnSalted");
return $passwordSalted === $hash || $passwordUnSalted === $hash || $password === $hash;
}
function isMobile() {
if (empty($_SERVER["HTTP_USER_AGENT"])) {
return false;
}
global $global;
require_once $global['systemRootPath'] . 'objects/Mobile_Detect.php';
$detect = new Mobile_Detect;
return $detect->isMobile();
}
function isAVideoMobileApp($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return false;
}
global $AVideoMobileAPP_UA;
if (preg_match("/{$AVideoMobileAPP_UA}(.*)/", $_SERVER["HTTP_USER_AGENT"], $match)) {
$url = trim($match[1]);
if (!empty($url)) {
return $url;
}
return true;
}
return false;
}
function isAVideoEncoder($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return false;
}
global $AVideoEncoder_UA;
if (preg_match("/{$AVideoEncoder_UA}(.*)/", $_SERVER["HTTP_USER_AGENT"], $match)) {
$url = trim($match[1]);
if (!empty($url)) {
return $url;
}
return true;
}
return false;
}
function isAVideo($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return false;
}
global $AVideoEncoder_UA;
if (preg_match("/AVideo(.*)/", $_SERVER["HTTP_USER_AGENT"], $match)) {
$url = trim($match[1]);
if (!empty($url)) {
return $url;
}
return true;
}
return false;
}
function isAVideoEncoderOnSameDomain() {
$url = isAVideoEncoder();
if (empty($url)) {
return false;
}
$url = "http://{$url}";
return isSameDomainAsMyAVideo($url);
}
function isSameDomainAsMyAVideo($url) {
global $global;
if (empty($url)) {
return false;
}
return isSameDomain($url, $global['webSiteRootURL']);
}
function requestComesFromSameDomainAsMyAVideo() {
global $global;
$url = "";
if (!empty($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
} elseif (!empty($_SERVER['HTTP_ORIGIN'])) {
$url = $_SERVER['HTTP_ORIGIN'];
}
return isSameDomain($url, $global['webSiteRootURL']);
}
function requestComesFromSafePlace() {
return (requestComesFromSameDomainAsMyAVideo() || isAVideo());
}
function addGlobalTokenIfSameDomain($url) {
if (!filter_var($url, FILTER_VALIDATE_URL) || (empty($_GET['livelink']) || !preg_match("/^http.*/i", $_GET['livelink']))) {
return $url;
}
if (!isSameDomainAsMyAVideo($url)) {
return $url;
}
return addQueryStringParameter($url, 'globalToken', getToken(60));
}
/**
* Remove a query string parameter from an URL.
*
* @param string $url
* @param string $varname
*
* @return string
*/
function removeQueryStringParameter($url, $varname) {
$parsedUrl = parse_url($url);
$query = array();
if (isset($parsedUrl['query'])) {
parse_str($parsedUrl['query'], $query);
unset($query[$varname]);
}
$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
$query = !empty($query) ? '?' . http_build_query($query) : '';
return $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $path . $query;
}
/**
* Add a query string parameter from an URL.
*
* @param string $url
* @param string $varname
*
* @return string
*/
function addQueryStringParameter($url, $varname, $value) {
$parsedUrl = parse_url($url);
$query = array();
if (isset($parsedUrl['query'])) {
parse_str($parsedUrl['query'], $query);
}
$query[$varname] = $value;
$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
$query = !empty($query) ? '?' . http_build_query($query) : '';
return $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $path . $query;
}
function isSameDomain($url1, $url2) {
if (empty($url1) || empty($url2)) {
return false;
}
return (get_domain($url1) === get_domain($url2));
}
function isAVideoStreamer($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return false;
}
global $AVideoStreamer_UA;
if (preg_match("/{$AVideoStreamer_UA}(.*)/", $_SERVER["HTTP_USER_AGENT"], $match)) {
$url = trim($match[1]);
if (!empty($url)) {
return $url;
}
return true;
}
return false;
}
function isAVideoStorage($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return false;
}
global $AVideoStorage_UA;
if (preg_match("/{$AVideoStorage_UA}(.*)/", $_SERVER["HTTP_USER_AGENT"], $match)) {
$url = trim($match[1]);
if (!empty($url)) {
return $url;
}
return true;
}
return false;
}
function get_domain($url, $ifEmptyReturnSameString = false) {
$pieces = parse_url($url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (empty($domain)) {
return $ifEmptyReturnSameString ? $url : false;
}
if (preg_match('/(?P[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
return $regs['domain'];
} else {
$isIp = (bool) ip2long($pieces['host']);
if ($isIp) {
return $pieces['host'];
}
}
return false;
}
function siteMap() {
_error_log("siteMap: start");
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 0);
global $global, $advancedCustom;
$date = date('Y-m-d\TH:i:s') . "+00:00";
$xml = '
' . $global['webSiteRootURL'] . '
' . $date . '
always
1.00
' . $global['webSiteRootURL'] . 'help
' . $date . '
monthly
0.50
' . $global['webSiteRootURL'] . 'about
' . $date . '
monthly
0.50
' . $global['webSiteRootURL'] . 'contact
' . $date . '
monthly
0.50
' . $global['webSiteRootURL'] . 'channels
' . $date . '
daily
0.80
';
$_REQUEST['rowCount'] = $advancedCustom->siteMapRowsLimit;
_error_log("siteMap: rowCount {$_REQUEST['rowCount']} ");
$_POST['sort']['modified'] = "DESC";
$users = User::getAllUsersThatHasVideos(true);
_error_log("siteMap: getAllUsers " . count($users));
foreach ($users as $value) {
$xml .= '
' . User::getChannelLink($value['id']) . '
' . $date . '
daily
0.90
';
}
$xml .= '
';
$_REQUEST['rowCount'] = $advancedCustom->siteMapRowsLimit;
$_POST['sort']['modified'] = "DESC";
$rows = Category::getAllCategories();
_error_log("siteMap: getAllCategories " . count($rows));
foreach ($rows as $value) {
$xml .= '
' . $global['webSiteRootURL'] . 'cat/' . $value['clean_name'] . '
' . $date . '
weekly
0.80
';
}
$xml .= '';
$_REQUEST['rowCount'] = $advancedCustom->siteMapRowsLimit * 10;
$_POST['sort']['created'] = "DESC";
$rows = Video::getAllVideos(!empty($advancedCustom->showPrivateVideosOnSitemap) ? "viewableNotUnlisted" : "publicOnly");
_error_log("siteMap: getAllVideos " . count($rows));
foreach ($rows as $video) {
$videos_id = $video['id'];
//_error_log("siteMap: getAllVideos videos_id {$videos_id} start");
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} elseif ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
}
if ($video['type'] === 'article') {
$type = 'article';
}
$images = Video::getImageFromFilename($video['filename'], $type);
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($images->posterPortraitPath);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = $images->poster;
}
$description = str_replace(array('"', "\n", "\r"), array('', ' ', ' '), empty(trim($video['description'])) ? $video['title'] : $video['description']);
$duration = parseDurationToSeconds($video['duration']);
if ($duration > 28800) {
// this is because this issue https://github.com/WWBN/AVideo/issues/3338 remove in the future if is not necessary anymore
$duration = 28800;
}
$xml .= '
' . Video::getLink($video['id'], $video['clean_title']) . '
' . $img . '
' . $duration . '
' . $video['views_count'] . '
' . date("Y-m-d\TH:i:s", strtotime($video['created'])) . '+00:00
yes
' . (Video::isPublic($video['id']) ? "no" : "yes") . '
' . User::getNameIdentificationById($video['users_id']) . '
no
';
}
$xml .= ' ';
_error_log("siteMap: done ");
$newXML1 = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $xml);
if (empty($newXML1)) {
_error_log("siteMap: pregreplace1 fail ");
$newXML1 = $xml;
}
if(!empty($advancedCustom->siteMapUTF8Fix)){
$newXML2 = preg_replace('/&(?!#?[a-z0-9]+;)/', '&', $newXML1);
if (empty($newXML2)) {
_error_log("siteMap: pregreplace2 fail ");
$newXML2 = $newXML1;
}
$newXML3 = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $newXML2);
if (empty($newXML3)) {
_error_log("siteMap: pregreplace3 fail ");
$newXML3 = $newXML2;
}
$newXML4 = preg_replace('/[\x00-\x1F\x7F]/', '', $newXML3);
if (empty($newXML4)) {
_error_log("siteMap: pregreplace4 fail ");
$newXML4 = $newXML3;
}
$newXML5 = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $newXML4);
if (empty($newXML5)) {
_error_log("siteMap: pregreplace5 fail ");
$newXML5 = $newXML4;
}
}else{
$newXML5 = $newXML1;
}
return $newXML5;
}
function object_to_array($obj) {
//only process if it's an object or array being passed to the function
if (is_object($obj) || is_array($obj)) {
$ret = (array) $obj;
foreach ($ret as &$item) {
//recursively process EACH element regardless of type
$item = object_to_array($item);
}
return $ret;
}
//otherwise (i.e. for scalar values) return without modification
else {
return $obj;
}
}
function allowOrigin() {
global $global;
if (empty($_SERVER['HTTP_ORIGIN'])) {
$server = parse_url($global['webSiteRootURL']);
header('Access-Control-Allow-Origin: ' . $server["scheme"] . '://imasdk.googleapis.com');
} else {
header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
}
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: GET,HEAD,OPTIONS,POST,PUT");
header("Access-Control-Allow-Headers: Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
}
function rrmdir($dir) {
global $global;
if ($dir == "{$global['systemRootPath']}videos/" || $dir == "{$global['systemRootPath']}videos") {
return false;
}
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir . "/" . $object)) {
rrmdir($dir . "/" . $object);
} else {
unlink($dir . "/" . $object);
}
}
}
rmdir($dir);
}
}
/**
* You can now configure it on the configuration.php
* @return boolean
*/
function ddosProtection() {
global $global;
$maxCon = empty($global['ddosMaxConnections']) ? 40 : $global['ddosMaxConnections'];
$secondTimeout = empty($global['ddosSecondTimeout']) ? 5 : $global['ddosSecondTimeout'];
$whitelistedFiles = array(
'playlists.json.php',
'playlistsFromUserVideos.json.php',
'image404.php'
);
if (in_array(basename($_SERVER["SCRIPT_FILENAME"]), $whitelistedFiles)) {
return true;
}
$time = time();
if (!isset($_SESSION['bruteForceBlock']) || empty($_SESSION['bruteForceBlock'])) {
$_SESSION['bruteForceBlock'] = array();
$_SESSION['bruteForceBlock'][] = $time;
return true;
}
$_SESSION['bruteForceBlock'][] = $time;
//remove requests that are older than secondTimeout
foreach ($_SESSION['bruteForceBlock'] as $key => $request_time) {
if ($request_time < $time - $secondTimeout) {
unset($_SESSION['bruteForceBlock'][$key]);
}
}
//progressive timeout-> more requests, longer timeout
$active_connections = count($_SESSION['bruteForceBlock']);
$timeoutReal = ($active_connections / $maxCon) < 1 ? 0 : ($active_connections / $maxCon) * $secondTimeout;
if ($timeoutReal) {
_error_log("ddosProtection:: progressive timeout timeoutReal = ($timeoutReal) active_connections = ($active_connections) maxCon = ($maxCon) ", AVideoLog::$SECURITY);
}
sleep($timeoutReal);
//with strict mode, penalize "attacker" with sleep() above, log and then die
if ($global['strictDDOSprotection'] && $timeoutReal > 0) {
$str = "bruteForceBlock: maxCon: $maxCon => secondTimeout: $secondTimeout | IP: " . getRealIpAddr() . " | count:" . count($_SESSION['bruteForceBlock']);
_error_log($str);
die($str);
}
return true;
}
function getAdsLeaderBoardBigVideo() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return trim($ad->leaderBoardBigVideoMobile->value);
} else {
return trim($ad->leaderBoardBigVideo->value);
}
}
}
function getAdsLeaderBoardTop() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->leaderBoardTopMobile->value;
} else {
return $ad->leaderBoardTop->value;
}
}
}
function getAdsChannelLeaderBoardTop() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->channelLeaderBoardTopMobile->value;
} else {
return $ad->channelLeaderBoardTop->value;
}
}
}
function getAdsLeaderBoardTop2() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->leaderBoardTopMobile2->value;
} else {
return $ad->leaderBoardTop2->value;
}
}
}
function getAdsLeaderBoardMiddle() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->leaderBoardMiddleMobile->value;
} else {
return $ad->leaderBoardMiddle->value;
}
}
}
function getAdsLeaderBoardFooter() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->leaderBoardFooterMobile->value;
} else {
return $ad->leaderBoardFooter->value;
}
}
}
function getAdsSideRectangle() {
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
if (!empty($ad)) {
if (isMobile()) {
return $ad->sideRectangle->value;
} else {
return $ad->sideRectangle->value;
}
}
}
function isToHidePrivateVideos() {
$obj = AVideoPlugin::getObjectDataIfEnabled("Gallery");
if (!empty($obj)) {
return $obj->hidePrivateVideos;
}
$obj = AVideoPlugin::getObjectDataIfEnabled("YouPHPFlix2");
if (!empty($obj)) {
return $obj->hidePrivateVideos;
}
$obj = AVideoPlugin::getObjectDataIfEnabled("YouTube");
if (!empty($obj)) {
return $obj->hidePrivateVideos;
}
return false;
}
function convertImageToOG($source, $destination) {
if (!file_exists($destination)) {
$w = 200;
$h = 200;
$sizes = getimagesize($source);
if ($sizes[0] < $w || $sizes[1] < $h) {
$tmpDir = getTmpDir();
$fileConverted = $tmpDir . "_jpg_" . uniqid() . ".jpg";
convertImage($source, $fileConverted, 100);
im_resizeV2($fileConverted, $destination, $w, $h, 100);
unlink($fileConverted);
}
}
return $destination;
}
function convertImageToRoku($source, $destination) {
if (empty($source)) {
_error_log("convertImageToRoku: source image is empty");
return false;
}
$w = 1280;
$h = 720;
if (file_exists($destination)) {
$sizes = getimagesize($destination);
if ($sizes[0] < $w || $sizes[1] < $h) {
_error_log("convertImageToRoku: file is smaller " . json_encode($sizes));
unlink($destination);
}
}
if (!file_exists($destination)) {
try {
$tmpDir = getTmpDir();
$fileConverted = $tmpDir . "_jpg_" . uniqid() . ".jpg";
convertImage($source, $fileConverted, 100);
im_resizeV2($fileConverted, $destination, $w, $h, 100);
@unlink($fileConverted);
} catch (Exception $exc) {
_error_log("convertImageToRoku: " . $exc->getMessage());
return false;
}
}
return $destination;
}
function ogSite() {
global $global, $config;
include $global['systemRootPath'] . 'objects/functionogSite.php';
}
function getOpenGraph($videos_id) {
global $global, $config, $advancedCustom;
include $global['systemRootPath'] . 'objects/functiongetOpenGraph.php';
}
function getLdJson($videos_id) {
$cache = ObjectYPT::getCache("getLdJson{$videos_id}", 0);
if (empty($cache)) {
echo $cache;
}
global $global, $config;
echo "";
if (empty($videos_id)) {
echo "";
if (!empty($_GET['videoName'])) {
echo "";
$video = Video::getVideoFromCleanTitle($_GET['videoName']);
}
} else {
echo "";
$video = Video::getVideoLight($videos_id);
}
if (empty($video)) {
echo "";
return false;
}
$videos_id = $video['id'];
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} elseif ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
}
if ($video['type'] === 'article') {
$type = 'article';
}
$images = Video::getImageFromFilename($video['filename'], $type);
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($images->posterPortraitPath);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = $images->poster;
}
$description = html2plainText(empty(trim($video['description'])) ? $video['title'] : $video['description']);
$duration = Video::getItemPropDuration($video['duration']);
if ($duration == "PT0H0M0S") {
$duration = "PT0H0M1S";
}
$output = '
';
ObjectYPT::setCache("getLdJson{$videos_id}", $output);
echo $output;
}
function getItemprop($videos_id) {
$cache = ObjectYPT::getCache("getItemprop{$videos_id}", 0);
if (empty($cache)) {
echo $cache;
}
global $global, $config;
echo "";
if (empty($videos_id)) {
echo "";
if (!empty($_GET['videoName'])) {
echo "";
$video = Video::getVideoFromCleanTitle($_GET['videoName']);
}
} else {
echo "";
$video = Video::getVideoLight($videos_id);
}
if (empty($video)) {
echo "";
return false;
}
$videos_id = $video['id'];
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} elseif ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
}
if ($video['type'] === 'image') {
$type = 'image';
}
if ($video['type'] === 'zip') {
$type = 'zip';
}
if ($video['type'] === 'article') {
$type = 'article';
}
$images = Video::getImageFromFilename($video['filename'], $type);
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($images->posterPortraitPath);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = $images->poster;
}
$description = html2plainText(empty(trim($video['description'])) ? $video['title'] : $video['description']);
$duration = Video::getItemPropDuration($video['duration']);
if ($duration == "PT0H0M0S") {
$duration = "PT0H0M1S";
}
$output = '
';
ObjectYPT::setCache("getItemprop{$videos_id}", $output);
echo $output;
}
function getOS($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
$os_platform = "Unknown OS Platform";
$os_array = array(
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
foreach ($os_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}
}
return $os_platform;
}
function get_browser_name($user_agent = "") {
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
if (empty($user_agent)) {
return 'Unknow';
}
// Make case insensitive.
$t = strtolower($user_agent);
// If the string *starts* with the string, strpos returns 0 (i.e., FALSE). Do a ghetto hack and start with a space.
// "[strpos()] may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE."
// http://php.net/manual/en/function.strpos.php
$t = " " . $t;
// Humans / Regular Users
if (isAVideoStreamer($t)) {
return 'AVideo Mobile App';
} elseif ($url = isAVideoEncoder($t)) {
return 'AVideo Encoder ' . $url;
} elseif ($url = isAVideoStreamer($t)) {
return 'AVideo Streamer ' . $url;
} elseif (strpos($t, 'crkey')) {
return 'Chromecast';
} elseif (strpos($t, 'opera') || strpos($t, 'opr/')) {
return 'Opera';
} elseif (strpos($t, 'edge')) {
return 'Edge';
} elseif (strpos($t, 'chrome')) {
return 'Chrome';
} elseif (strpos($t, 'safari')) {
return 'Safari';
} elseif (strpos($t, 'firefox')) {
return 'Firefox';
} elseif (strpos($t, 'msie') || strpos($t, 'trident/7')) {
return 'Internet Explorer';
} elseif (strpos($t, 'applecoremedia')) {
return 'Native Apple Player';
}
// Search Engines
elseif (strpos($t, 'google')) {
return '[Bot] Googlebot';
} elseif (strpos($t, 'bing')) {
return '[Bot] Bingbot';
} elseif (strpos($t, 'slurp')) {
return '[Bot] Yahoo! Slurp';
} elseif (strpos($t, 'duckduckgo')) {
return '[Bot] DuckDuckBot';
} elseif (strpos($t, 'baidu')) {
return '[Bot] Baidu';
} elseif (strpos($t, 'yandex')) {
return '[Bot] Yandex';
} elseif (strpos($t, 'sogou')) {
return '[Bot] Sogou';
} elseif (strpos($t, 'exabot')) {
return '[Bot] Exabot';
} elseif (strpos($t, 'msn')) {
return '[Bot] MSN';
}
// Common Tools and Bots
elseif (strpos($t, 'mj12bot')) {
return '[Bot] Majestic';
} elseif (strpos($t, 'ahrefs')) {
return '[Bot] Ahrefs';
} elseif (strpos($t, 'semrush')) {
return '[Bot] SEMRush';
} elseif (strpos($t, 'rogerbot') || strpos($t, 'dotbot')) {
return '[Bot] Moz or OpenSiteExplorer';
} elseif (strpos($t, 'frog') || strpos($t, 'screaming')) {
return '[Bot] Screaming Frog';
}
// Miscellaneous
elseif (strpos($t, 'facebook')) {
return '[Bot] Facebook';
} elseif (strpos($t, 'pinterest')) {
return '[Bot] Pinterest';
}
// Check for strings commonly used in bot user agents
elseif (strpos($t, 'crawler') || strpos($t, 'api') ||
strpos($t, 'spider') || strpos($t, 'http') ||
strpos($t, 'bot') || strpos($t, 'archive') ||
strpos($t, 'info') || strpos($t, 'data')) {
return '[Bot] Other';
}
//_error_log("Unknow user agent ($t) IP=" . getRealIpAddr() . " URI=" . getRequestURI());
return 'Other (Unknown)';
}
/**
* Due some error on old chrome browsers (version < 70) on decrypt HLS keys with the videojs versions greater then 7.9.7
* we need to detect the chrome browser and load an older version
*
*/
function isOldChromeVersion() {
$global;
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return false;
}
if (!empty($global['forceOldChrome'])) {
return true;
}
if (preg_match('/Chrome\/([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
return version_compare($matches[1], '80', '<=');
}
return false;
}
function TimeLogStart($name) {
global $global;
if (!empty($global['noDebug'])) {
return false;
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
if (empty($global['start']) || !is_array($global['start'])) {
$global['start'] = array();
}
$global['start'][$name] = $time;
}
function TimeLogEnd($name, $line, $TimeLogLimit = 0.7) {
global $global;
if (!empty($global['noDebug'])) {
return false;
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $global['start'][$name]), 4);
if ($total_time > $TimeLogLimit) {
_error_log("Warning: Slow process detected [{$name}] On Line {$line} takes {$total_time} seconds to complete, Limit ({$TimeLogLimit}). {$_SERVER["SCRIPT_FILENAME"]}");
}
TimeLogStart($name);
}
class AVideoLog
{
public static $DEBUG = 0;
public static $WARNING = 1;
public static $ERROR = 2;
public static $SECURITY = 3;
}
function _error_log($message, $type = 0, $doNotRepeat = false) {
if (empty($doNotRepeat)) {
// do not log it too many times when you are using HLS format, other wise it will fill the log file with the same error
$doNotRepeat = preg_match("/hls.php$/", $_SERVER['SCRIPT_NAME']);
}
if ($doNotRepeat) {
return false;
}
global $global;
if (!empty($global['noDebug']) && $type == 0) {
return false;
}
$prefix = "AVideoLog::";
switch ($type) {
case AVideoLog::$DEBUG:
$prefix .= "DEBUG: ";
break;
case AVideoLog::$WARNING:
$prefix .= "WARNING: ";
break;
case AVideoLog::$ERROR:
$prefix .= "ERROR: ";
break;
case AVideoLog::$SECURITY:
$prefix .= "SECURITY: ";
break;
}
error_log($prefix . $message . " SCRIPT_NAME: {$_SERVER['SCRIPT_NAME']}");
}
function postVariables($url, $array) {
if (!$url || !is_string($url) || !preg_match('/^http(s)?:\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i', $url)) {
return false;
}
$array = object_to_array($array);
$ch = curl_init($url);
@curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
@curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $array);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// execute!
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// close the connection, release resources used
curl_close($ch);
if ($httpcode == 200) {
return true;
}
return $httpcode;
}
function _session_start(array $options = array()) {
try {
if (session_status() == PHP_SESSION_NONE) {
return @session_start($options);
}
} catch (Exception $exc) {
_error_log("_session_start: " . $exc->getTraceAsString());
return false;
}
}
function _mysql_connect() {
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort;
if (is_object($global['mysqli']) && empty(@$global['mysqli']->ping())) {
try {
$global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort);
if (!empty($global['mysqli_charset'])) {
$global['mysqli']->set_charset($global['mysqli_charset']);
}
} catch (Exception $exc) {
_error_log($exc->getTraceAsString());
return false;
}
}
}
function _mysql_close() {
global $global;
if (is_object($global['mysqli']) && !empty(@$global['mysqli']->ping())) {
@$global['mysqli']->close();
}
}
function remove_utf8_bom($text) {
if (strlen($text) > 1000000) {
return $text;
}
$bom = pack('H*', 'EFBBBF');
$text = preg_replace("/^$bom/", '', $text);
return $text;
}
function getCacheDir() {
$p = AVideoPlugin::loadPlugin("Cache");
return $p->getCacheDir();
}
function clearCache() {
global $global;
$dir = "{$global['systemRootPath']}videos/cache/";
if (!empty($_GET['FirstPage'])) {
$dir .= "firstPage/";
}
rrmdir($dir);
$dir = getCacheDir();
if (!empty($_GET['FirstPage'])) {
$dir .= "firstPage/";
}
rrmdir($dir);
ObjectYPT::deleteCache("getEncoderURL");
}
function getUsageFromFilename($filename, $dir = "") {
global $global;
if (!empty($global['getUsageFromFilename'])) { // manually add this variable in your configuration.php file to not scan your video usage
return 0;
}
if (empty($dir)) {
$dir = "{$global['systemRootPath']}videos/";
}
$pos = strrpos($dir, '/');
$dir .= (($pos === false) ? "/" : "");
$totalSize = 0;
_error_log("getUsageFromFilename: start {$dir}{$filename}");
//$files = glob("{$dir}{$filename}*");
$files = globVideosDir($filename);
session_write_close();
$filesProcessed = array();
if (empty($files)) {
_error_log("getUsageFromFilename: we did not find any file for {$dir}{$filename}, we will create a fake one");
file_put_contents("{$dir}{$filename}.notfound", time());
$totalSize = 10;
} else {
foreach ($files as $f) {
if (strpos($f, '.size.lock') !== false) {
continue;
}
if (is_dir($f)) {
_error_log("getUsageFromFilename: {$f} is Dir");
$dirSize = getDirSize($f);
$totalSize += $dirSize;
if ($dirSize < 10000 && AVideoPlugin::isEnabledByName('YPTStorage')) {
// probably the HLS file is hosted on the YPTStorage
$info = YPTStorage::getFileInfo($filename);
if (!empty($info->size)) {
$totalSize += $info->size;
}
}
} elseif (is_file($f)) {
$filesize = filesize($f);
if ($filesize < 20) { // that means it is a dummy file
$lockFile = $f . ".size.lock";
if (!file_exists($lockFile) || (time() - 600) > filemtime($lockFile)) {
file_put_contents($lockFile, time());
_error_log("getUsageFromFilename: {$f} is Dummy file ({$filesize})");
$aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
//$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
if (!empty($aws_s3)) {
_error_log("getUsageFromFilename: Get from S3");
$filesize += $aws_s3->getFilesize($filename);
} elseif (!empty($bb_b2)) {
// TODO
} else {
$urls = Video::getVideosPaths($filename, true);
_error_log("getUsageFromFilename: Paths " . json_encode($urls));
if (!empty($urls["m3u8"]['url'])) {
$filesize += getUsageFromURL($urls["m3u8"]['url']);
}
if (!empty($urls['mp4'])) {
foreach ($urls['mp4'] as $mp4) {
if (in_array($mp4, $filesProcessed)) {
continue;
}
$filesProcessed[] = $mp4;
$filesize += getUsageFromURL($mp4);
}
}
if (!empty($urls['webm'])) {
foreach ($urls['webm'] as $mp4) {
if (in_array($mp4, $filesProcessed)) {
continue;
}
$filesProcessed[] = $mp4;
$filesize += getUsageFromURL($mp4);
}
}
if (!empty($urls["pdf"]['url'])) {
$filesize += getUsageFromURL($urls["pdf"]['url']);
}
if (!empty($urls["image"]['url'])) {
$filesize += getUsageFromURL($urls["image"]['url']);
}
if (!empty($urls["zip"]['url'])) {
$filesize += getUsageFromURL($urls["zip"]['url']);
}
if (!empty($urls["mp3"]['url'])) {
$filesize += getUsageFromURL($urls["mp3"]['url']);
}
}
unlink($lockFile);
}
} else {
_error_log("getUsageFromFilename: {$f} is File ({$filesize})");
}
$totalSize += $filesize;
}
}
}
return $totalSize;
}
/**
* Returns the size of a file without downloading it, or -1 if the file
* size could not be determined.
*
* @param $url - The location of the remote file to download. Cannot
* be null or empty.
*
* @return The size of the file referenced by $url, or false if the size
* could not be determined.
*/
function getUsageFromURL($url) {
global $global;
if (!empty($global['doNotGetUsageFromURL'])) { // manually add this variable in your configuration.php file to not scan your video usage
return 0;
}
_error_log("getUsageFromURL: start ({$url})");
// Assume failure.
$result = false;
$curl = curl_init($url);
_error_log("getUsageFromURL: curl_init ");
try {
// Issue a HEAD request and follow any redirects.
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($curl, CURLOPT_USERAGENT, get_user_agent_string());
$data = curl_exec($curl);
} catch (Exception $exc) {
echo $exc->getTraceAsString();
_error_log("getUsageFromURL: ERROR " . $exc->getMessage());
_error_log("getUsageFromURL: ERROR " . curl_errno($curl));
_error_log("getUsageFromURL: ERROR " . curl_error($curl));
}
if ($data) {
_error_log("getUsageFromURL: response header " . $data);
$content_length = "unknown";
$status = "unknown";
if (preg_match("/^HTTP\/1\.[01] (\d\d\d)/", $data, $matches)) {
$status = (int) $matches[1];
}
if (preg_match("/Content-Length: (\d+)/", $data, $matches)) {
$content_length = (int) $matches[1];
}
// http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
if ($status == 200 || ($status > 300 && $status <= 308)) {
$result = $content_length;
}
} else {
_error_log("getUsageFromURL: ERROR no response data " . curl_error($curl));
}
curl_close($curl);
return (int) $result;
}
function getDirSize($dir) {
_error_log("getDirSize: start {$dir}");
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return foldersize($dir);
} else {
$command = "du -sb {$dir}";
exec($command . " < /dev/null 2>&1", $output, $return_val);
if ($return_val !== 0) {
_error_log("getDirSize: ERROR ON Command {$command}");
return 0;
} else {
if (!empty($output[0])) {
preg_match("/^([0-9]+).*/", $output[0], $matches);
}
if (!empty($matches[1])) {
_error_log("getDirSize: found {$matches[1]} from - {$output[0]}");
return intval($matches[1]);
}
_error_log("getDirSize: ERROR on pregmatch {$output[0]}");
return 0;
}
}
}
function foldersize($path) {
$total_size = 0;
$files = scandir($path);
$cleanPath = rtrim($path, '/') . '/';
foreach ($files as $t) {
if ($t <> "." && $t <> "..") {
$currentFile = $cleanPath . $t;
if (is_dir($currentFile)) {
$size = foldersize($currentFile);
$total_size += $size;
} else {
$size = filesize($currentFile);
$total_size += $size;
}
}
}
return $total_size;
}
function getDiskUsage() {
global $global;
$dir = "{$global['systemRootPath']}videos/";
$obj = new stdClass();
$obj->disk_free_space = disk_free_space($dir);
$obj->disk_total_space = disk_total_space($dir);
$obj->videos_dir = getDirSize($dir);
$obj->disk_used = $obj->disk_total_space - $obj->disk_free_space;
$obj->disk_used_by_other = $obj->disk_used - $obj->videos_dir;
$obj->disk_free_space_human = humanFileSize($obj->disk_free_space);
$obj->disk_total_space_human = humanFileSize($obj->disk_total_space);
$obj->videos_dir_human = humanFileSize($obj->videos_dir);
$obj->disk_used_human = humanFileSize($obj->disk_used);
$obj->disk_used_by_other_human = humanFileSize($obj->disk_used_by_other);
// percentage of disk used
$obj->disk_used_percentage = sprintf('%.2f', ($obj->disk_used / $obj->disk_total_space) * 100);
$obj->videos_dir_used_percentage = sprintf('%.2f', ($obj->videos_dir / $obj->disk_total_space) * 100);
$obj->disk_free_space_percentage = sprintf('%.2f', ($obj->disk_free_space / $obj->disk_total_space) * 100);
return $obj;
}
function unsetSearch() {
unset($_GET['searchPhrase']);
unset($_POST['searchPhrase']);
unset($_GET['search']);
unset($_GET['q']);
}
function encrypt_decrypt($string, $action) {
global $global;
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = 'This is my secret key';
$secret_iv = $global['systemRootPath'];
while (strlen($secret_iv) < 16) {
$secret_iv .= $global['systemRootPath'];
}
// hash
$key = hash('sha256', $global['salt']);
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ($action == 'encrypt') {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} elseif ($action == 'decrypt') {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}
function compressString($string) {
if (function_exists("gzdeflate")) {
$string = gzdeflate($string, 9);
}
return $string;
}
function decompressString($string) {
if (function_exists("gzinflate")) {
$string = gzinflate($string);
}
return $string;
}
function encryptString($string) {
if (is_object($string)) {
$string = json_encode($string);
}
return encrypt_decrypt($string, 'encrypt');
}
function decryptString($string) {
return encrypt_decrypt($string, 'decrypt');
}
function getToken($timeout = 0, $salt = "") {
global $global;
$obj = new stdClass();
$obj->salt = $global['salt'] . $salt;
if (!empty($timeout)) {
$obj->time = time();
$obj->timeout = $obj->time + $timeout;
} else {
$obj->time = strtotime("Today 00:00:00");
$obj->timeout = strtotime("Today 23:59:59");
$obj->timeout += cacheExpirationTime();
}
$strObj = json_encode($obj);
//_error_log("Token created: {$strObj}");
return encryptString($strObj);
}
function verifyToken($token, $salt = "") {
global $global;
$obj = json_decode(decryptString($token));
if (empty($obj)) {
_error_log("verifyToken invalid token");
return false;
}
if ($obj->salt !== $global['salt'] . $salt) {
_error_log("verifyToken salt fail");
return false;
}
$time = time();
if (!($time >= $obj->time && $time <= $obj->timeout)) {
_error_log("verifyToken token timout time = $time; obj->time = $obj->time; obj->timeout = $obj->timeout");
return false;
}
return true;
}
class YPTvideoObject
{
public $id;
public $title;
public $description;
public $thumbnails;
public $channelTitle;
public $videoLink;
public function __construct($id, $title, $description, $thumbnails, $channelTitle, $videoLink)
{
$this->id = $id;
$this->title = $title;
$this->description = $description;
$this->thumbnails = $thumbnails;
$this->channelTitle = $channelTitle;
$this->videoLink = $videoLink;
}
}
function isToShowDuration($type) {
$notShowTo = array('pdf', 'article', 'serie', 'zip', 'image');
if (in_array($type, $notShowTo)) {
return false;
} else {
return true;
}
}
function _dieAndLogObject($obj, $prefix = "") {
$objString = json_encode($obj);
_error_log($prefix . $objString);
die($objString);
}
function isAVideoPlayer() {
if (isVideo()) {
return true;
}
return false;
}
function isVideo() {
global $isModeYouTube;
return !empty($isModeYouTube) || isPlayList() || isEmbed() || isLive();
}
function isAudio() {
global $isAudio;
return !empty($isAudio);
}
function isSerie() {
return isPlayList();
}
function isPlayList() {
global $isPlayList, $isSerie;
return !empty($isSerie) || !empty($isPlayList);
}
function isChannel() {
global $isChannel;
if (!empty($isChannel) && !isVideo()) {
$user_id = 0;
if (empty($_GET['channelName'])) {
if (User::isLogged()) {
$user_id = User::getId();
} else {
return false;
}
} else {
$_GET['channelName'] = xss_esc($_GET['channelName']);
$user = User::getChannelOwner($_GET['channelName']);
if (!empty($user)) {
$user_id = $user['id'];
} else {
$user_id = $_GET['channelName'];
}
}
return $user_id;
}
return false;
}
function isEmbed() {
global $isEmbed;
return !empty($isEmbed);
}
function isLive() {
global $isLive;
return !empty($isLive);
}
function isVideoPlayerHasProgressBar() {
if (isLive()) {
$obj = AVideoPlugin::getObjectData('Live');
if (empty($obj->disableDVR)) {
return true;
}
} elseif (isAVideoPlayer()) {
return true;
}
return false;
}
function isHLS() {
global $video, $global;
if (isLive()) {
return true;
} elseif (!empty($video) && $video['type'] == 'video' && file_exists("{$global['systemRootPath']}videos/{$video['filename']}/index.m3u8")) {
return true;
}
return false;
}
function getRedirectUri() {
if (!empty($_GET['redirectUri'])) {
return $_GET['redirectUri'];
}
if (!empty($_SERVER["HTTP_REFERER"])) {
return $_SERVER["HTTP_REFERER"];
}
return getRequestURI();
}
function getRequestURI() {
if (empty($_SERVER['REQUEST_URI'])) {
return "";
}
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
function getSelfURI() {
if (empty($_SERVER['PHP_SELF'])) {
return "";
}
$queryStringWithoutError = preg_replace("/error=[^&]*/", "", $_SERVER['QUERY_STRING']);
$phpselfWithoutIndex = preg_replace("/index.php/", "", $_SERVER['PHP_SELF']);
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$phpselfWithoutIndex?$queryStringWithoutError";
$url = rtrim($url, '?');
return $url;
}
function isSameVideoAsSelfURI($url) {
return URLsAreSameVideo($url, getSelfURI());
}
function URLsAreSameVideo($url1, $url2) {
return getVideoIDFromURL($url1) == getVideoIDFromURL($url2);
}
function getVideoIDFromURL($url) {
if (preg_match("/v=([0-9]+)/", $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/video\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/videoEmbed\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/v\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/vEmbed\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/article\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
if (preg_match('/\/articleEmbed\/([0-9]+)/', $url, $matches)) {
return intval($matches[1]);
}
}
function getBackURL() {
global $global;
$backURL = getRedirectUri();
if (empty($backURL)) {
$backURL = getRequestURI();
}
if (isSameVideoAsSelfURI($backURL)) {
$backURL = getHomeURL();
}
return $backURL;
}
function getHomeURL() {
global $global, $advancedCustomUser, $advancedCustom;
if (isValidURL($advancedCustomUser->afterLoginGoToURL)) {
return $advancedCustomUser->afterLoginGoToURL;
} elseif (isValidURL($advancedCustom->logoMenuBarURL) && isSameDomainAsMyAVideo($advancedCustom->logoMenuBarURL)) {
return $advancedCustom->logoMenuBarURL;
}
return $global['webSiteRootURL'];
}
function isValidURL($url) {
if (empty($url) || !is_string($url)) {
return false;
}
if (preg_match("/^http.*/", $url) && filter_var($url, FILTER_VALIDATE_URL)) {
return true;
}
return false;
}
function hasLastSlash($word) {
return substr($word, -1) === '/';
}
function addLastSlash($word) {
return $word . (hasLastSlash($word) ? "" : "/");
}
function URLHasLastSlash() {
return hasLastSlash($_SERVER["REQUEST_URI"]);
}
-function getSEOComplement() {
- $txt = "";
- if (!empty($_GET['catName'])) {
- $txt .= " {$_GET['catName']}";
+function ucname($str) {
+ $str = ucwords(strtolower($str));
+
+ foreach(array('\'', '-') as $delim) {
+ if (strpos($str, $delim) !== false) {
+ $str = implode($delim, array_map('ucfirst', explode($delim, $str)));
+ }
+ }
+ return $str;
+}
+
+function sanitize_input($input) {
+ return htmlentities(strip_tags($input));
+}
+
+function sanitize_array_item(&$item, $key) {
+ $item = sanitize_input($item);
+}
+
+function getSEOComplement($parameters = array()) {
+ global $config;
+
+ $allowedTypes = isset($parameters["allowedTypes"]) ? $parameters["allowedTypes"] : null;
+ $addAutoPrefix = isset($parameters["addAutoPrefix"]) ? $parameters["addAutoPrefix"] : true;
+ $addCategory = isset($parameters["addCategory"]) ? $parameters["addCategory"] : true;
+
+ $parts = array();
+
+ if (!empty($_GET['error'])) {
+ array_push($parts, __("Error"));
}
- if (!empty($_GET['page'])) {
- $page = intval($_GET['page']);
- if ($page > 1) {
- $txt .= " / {$page}";
- }
+
+ if ($addCategory && !empty($_GET['catName'])) {
+ array_push($parts, $_GET['catName']);
}
+
if (!empty($_GET['channelName'])) {
- $txt .= " {$_GET['channelName']}";
+ array_push($parts, $_GET['channelName']);
}
+
if (!empty($_GET['type'])) {
- $txt .= " {$_GET['type']}";
+ $type = $_GET['type'];
+ if (empty($allowedTypes) || in_array(strtolower($type), $allowedTypes)) {
+ array_push($parts, __(ucname($type)));
+ }
}
+
if (!empty($_GET['showOnly'])) {
- $txt .= " {$_GET['showOnly']}";
+ array_push($parts, $_GET['showOnly']);
}
- if (!empty($_GET['error'])) {
- $txt .= " " . __("Error");
- }
- if (URLHasLastSlash()) {
- $txt .= "‧";
- }
- if (strrpos($_SERVER['HTTP_HOST'], 'www.') === false) {
- $txt = "‧{$txt}";
- }
- if (!empty($_GET['error'])) {
- $txt .= "‧‧";
+
+ if (!empty($_GET['page'])) {
+ $page = intval($_GET['page']);
+ if ($page > 1) {
+ array_push($parts, sprintf(__("Page %d"), $page));
+ }
}
- return htmlentities(strip_tags($txt));
+
+ // Cleaning all entries in the $parts array
+ array_walk($parts, 'sanitize_array_item');
+
+ $txt = implode($config->getPageTitleSeparator(), $parts);
+ $txt = (!empty($txt) && $addAutoPrefix ? $config->getPageTitleSeparator() : "") . $txt;
+
+ return $txt;
}
function getCurrentPage() {
if (!empty($_REQUEST['current'])) {
return intval($_REQUEST['current']);
} elseif (!empty($_POST['current'])) {
return intval($_POST['current']);
} elseif (!empty($_GET['current'])) {
return intval($_GET['current']);
} elseif (isset($_GET['start']) && isset($_GET['length'])) { // for the bootgrid
$start = intval($_GET['start']);
$length = intval($_GET['length']);
if (!empty($start) && !empty($length)) {
return floor($start / $length) + 1;
}
}
return 1;
}
function getRowCount($default = 1000) {
global $global;
if (!empty($_REQUEST['rowCount'])) {
$defaultN = intval($_REQUEST['rowCount']);
} elseif (!empty($_POST['rowCount'])) {
$defaultN = intval($_POST['rowCount']);
} elseif (!empty($_GET['rowCount'])) {
$defaultN = intval($_GET['rowCount']);
} elseif (!empty($_REQUEST['length'])) {
$defaultN = intval($_REQUEST['length']);
} elseif (!empty($_POST['length'])) {
$defaultN = intval($_POST['length']);
} elseif (!empty($_GET['length'])) {
$defaultN = intval($_GET['length']);
} elseif (!empty($global['rowCount'])) {
$defaultN = intval($global['rowCount']);
}
return (!empty($defaultN) && $defaultN > 0) ? $defaultN : $default;
}
function getSearchVar() {
if (!empty($_REQUEST['search'])) {
return $_REQUEST['search'];
} elseif (!empty($_REQUEST['q'])) {
return $_REQUEST['q'];
}
if (!empty($_REQUEST['searchPhrase'])) {
return $_REQUEST['searchPhrase'];
} elseif (!empty($_REQUEST['search']['value'])) {
return $_REQUEST['search']['value'];
}
return "";
}
$cleanSearchHistory = "";
function cleanSearchVar() {
global $cleanSearchHistory;
$search = getSearchVar();
if (!empty($search)) {
$cleanSearchHistory = $search;
}
$searchIdex = array('q', 'searchPhrase', 'search');
foreach ($searchIdex as $value) {
unset($_REQUEST[$value]);
unset($_POST[$value]);
unset($_GET[$value]);
}
}
function reloadSearchVar() {
global $cleanSearchHistory;
$_REQUEST['search'] = $cleanSearchHistory;
if (empty($_GET['search'])) {
$_GET['search'] = $cleanSearchHistory;
}
if (empty($_POST['search'])) {
$_POST['search'] = $cleanSearchHistory;
}
}
function wget($url, $filename, $debug = false) {
if (empty($url) || $url == "php://input" || !preg_match("/^http/", $url)) {
return false;
}
if (wgetIsLocked($url)) {
if ($debug) {
_error_log("wget: ERROR the url is already downloading $url, $filename");
}
return false;
}
wgetLock($url);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$content = file_get_contents($url);
if (!empty($content) && file_put_contents($filename, $content) > 100) {
wgetRemoveLock($url);
return true;
}
wgetRemoveLock($url);
return false;
}
$cmd = "wget --tries=1 {$url} -O {$filename} --no-check-certificate";
if ($debug) {
_error_log("wget Start ({$cmd}) ");
}
//echo $cmd;
exec($cmd);
wgetRemoveLock($url);
if (!file_exists($filename)) {
_error_log("wget: ERROR the url does not download $url, $filename");
return false;
}
if (empty(filesize($filename))) {
_error_log("wget: ERROR the url download but is empty $url, $filename");
return true;
}
return false;
}
function wgetLockFile($url) {
return getTmpDir("YPTWget") . md5($url) . ".lock";
}
function wgetLock($url) {
$file = wgetLockFile($url);
return file_put_contents($file, time() . PHP_EOL, FILE_APPEND | LOCK_EX);
}
function wgetRemoveLock($url) {
$filename = wgetLockFile($url);
if (!file_exists($filename)) {
return false;
}
return unlink($filename);
}
function getLockFile($name) {
return getTmpDir("YPTLockFile") . md5($name) . ".lock";
}
function setLock($name) {
$file = getLockFile($name);
return file_put_contents($file, time());
}
function isLock($name, $timeout = 60) {
$file = getLockFile($name);
if (file_exists($file)) {
$time = intval(file_get_contents($file));
if ($time + $timeout < time()) {
return false;
}
}
}
function removeLock($name) {
$filename = getLockFile($name);
if (!file_exists($filename)) {
return false;
}
return unlink($filename);
}
function wgetIsLocked($url) {
$filename = wgetLockFile($url);
if (!file_exists($filename)) {
return false;
}
$time = intval(file_get_contents($filename));
if (time() - $time > 36000) { // more then 10 hours
unlink($filename);
return false;
}
return true;
}
// due the some OS gives a fake is_writable response
function isWritable($dir) {
$dir = rtrim($dir, '/') . '/';
$file = $dir . uniqid();
$result = false;
$time = time();
if (@file_put_contents($file, $time)) {
if ($fileTime = @file_get_contents($file)) {
if ($fileTime == $time) {
$result = true;
}
}
}
@unlink($file);
return $result;
}
function _isWritable($dir) {
if (!isWritable($dir)) {
return false;
}
$tmpFile = "{$dir}" . uniqid();
$bytes = @file_put_contents($tmpFile, time());
@unlink($tmpFile);
return !empty($bytes);
}
function getTmpDir($subdir = "") {
global $global;
if (empty($_SESSION['getTmpDir'])) {
$_SESSION['getTmpDir'] = array();
}
if (empty($_SESSION['getTmpDir'][$subdir . "_"])) {
$tmpDir = sys_get_temp_dir();
if (empty($tmpDir) || !_isWritable($tmpDir)) {
$tmpDir = "{$global['systemRootPath']}videos/cache/";
}
$tmpDir = rtrim($tmpDir, '/') . '/';
$tmpDir = "{$tmpDir}{$subdir}";
$tmpDir = rtrim($tmpDir, '/') . '/';
if (!is_dir($tmpDir)) {
mkdir($tmpDir, 0755, true);
}
_session_start();
$_SESSION['getTmpDir'][$subdir . "_"] = $tmpDir;
} else {
$tmpDir = $_SESSION['getTmpDir'][$subdir . "_"];
}
return $tmpDir;
}
function getTmpFile() {
return getTmpDir("tmpFiles") . uniqid();
}
function getMySQLDate() {
global $global;
$sql = "SELECT now() as time FROM configurations LIMIT 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data['time'];
} else {
$row = false;
}
return $row;
}
function _file_put_contents($filename, $data, $flags = 0, $context = null) {
make_path($filename);
return file_put_contents($filename, $data, $flags, $context);
}
function html2plainText($html) {
$text = strip_tags($html);
$text = str_replace(array('\\', "\n", "\r", '"'), array('', ' ', ' ', ''), trim($text));
return $text;
}
function getInputPassword($id, $attributes = 'class="form-control"', $paceholder = '') {
if (empty($paceholder)) {
$paceholder = __("Password");
} ?>
>
>
data-toggle="tooltip" data-placement="left" title="">
" . PHP_EOL;
} else {
return __LINE__;
}
$object = object_to_array($object);
$json = json_encode($object);
if (json_last_error()) {
echo "Error 1 Found after array conversion: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
$json = json_encode($object, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
echo "Error 1 Found with JSON_UNESCAPED_UNICODE: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
$objectEncoded = $object;
array_walk_recursive($objectEncoded, function (&$item) {
if (is_string($item)) {
$item = utf8_encode($item);
}
});
$json = json_encode($objectEncoded);
if (json_last_error()) {
echo "Error 2 Found after array conversion: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
$json = json_encode($objectEncoded, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
echo "Error 2 Found with JSON_UNESCAPED_UNICODE: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
$objectDecoded = $object;
array_walk_recursive($objectDecoded, function (&$item) {
if (is_string($item)) {
$item = utf8_decode($item);
}
});
$json = json_encode($objectDecoded);
if (json_last_error()) {
echo "Error 2 Found after array conversion: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
$json = json_encode($objectDecoded, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
echo "Error 2 Found with JSON_UNESCAPED_UNICODE: " . json_last_error_msg() . " " . PHP_EOL;
} else {
return __LINE__;
}
return false;
}
function _json_encode($object) {
if (empty($object)) {
return false;
}
$json = json_encode($object);
if (json_last_error()) {
_error_log("_json_encode: Error 1 Found: " . json_last_error_msg());
$object = object_to_array($object);
$json = json_encode($object);
if (json_last_error()) {
_error_log("_json_encode: Error 2 Found: " . json_last_error_msg());
$json = json_encode($object, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
_error_log("_json_encode: Error 3 Found: " . json_last_error_msg());
$objectEncoded = $object;
array_walk_recursive($objectEncoded, function (&$item) {
if (is_string($item)) {
$item = utf8_encode($item);
}
});
$json = json_encode($objectEncoded);
if (json_last_error()) {
_error_log("_json_encode: Error 4 Found: " . json_last_error_msg());
$json = json_encode($objectEncoded, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
_error_log("_json_encode: Error 5 Found: " . json_last_error_msg());
$objectDecoded = $object;
array_walk_recursive($objectDecoded, function (&$item) {
if (is_string($item)) {
$item = utf8_decode($item);
}
});
$json = json_encode($objectDecoded);
if (json_last_error()) {
_error_log("_json_encode: Error 6 Found: " . json_last_error_msg());
$json = json_encode($objectDecoded, JSON_UNESCAPED_UNICODE);
if (json_last_error()) {
_error_log("_json_encode: Error 7 Found: " . json_last_error_msg());
}
}
}
}
}
}
}
return $json;
}
// this will make sure the strring will fits in the database field
function _substr($string, $start, $length = null) {
// make sure the name is not chunked in case of multibyte string
if (function_exists("mb_strcut")) {
return mb_strcut($string, $start, $length, "UTF-8");
} else {
return substr($string, $start, $length);
}
}
function getPagination($total, $page = 0, $link = "", $maxVisible = 10, $infinityScrollGetFromSelector = "", $infinityScrollAppendIntoSelector = "") {
global $global, $advancedCustom;
if ($total < 2) {
return "";
}
$uid = md5($link);
if ($total < $maxVisible) {
$maxVisible = $total;
}
if (empty($link)) {
$link = getSelfURI();
if (preg_match("/(current=[0-9]+)/i", $link, $match)) {
$link = str_replace($match[1], "current={page}", $link);
} else {
$link .= (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'current={page}';
}
}
if (empty($page)) {
$page = getCurrentPage();
}
$class = "";
if (!empty($infinityScrollGetFromSelector) && !empty($infinityScrollAppendIntoSelector)) {
$class = "infiniteScrollPagination{$uid} hidden";
}
$pag = ' ';
if (!empty($infinityScrollGetFromSelector) && !empty($infinityScrollAppendIntoSelector)) {
$content = file_get_contents($global['systemRootPath'] . 'objects/functiongetPagination.php');
$pag .= str_replace(
array('$uid', '$webSiteRootURL', '$infinityScrollGetFromSelector', '$infinityScrollAppendIntoSelector'),
array($uid, $global['webSiteRootURL'], $infinityScrollGetFromSelector, $infinityScrollAppendIntoSelector),
$content
);
}
return $pag;
}
function getShareMenu($title, $permaLink, $URLFriendly, $embedURL, $img, $class = "row bgWhite list-group-item menusDiv") {
global $global, $advancedCustom;
include $global['systemRootPath'] . 'objects/functiongetShareMenu.php';
}
function getSharePopupButton($videos_id, $url = "", $title = "") {
global $global, $advancedCustom;
if ($advancedCustom->disableShareOnly || $advancedCustom->disableShareAndPlaylist) {
return false;
}
$video['id'] = $videos_id;
include $global['systemRootPath'] . 'view/include/socialModal.php';
}
function forbiddenPage($message, $logMessage = false) {
global $global;
$_REQUEST['403ErrorMsg'] = $message;
if ($logMessage) {
_error_log($message);
}
include $global['systemRootPath'] . 'view/forbiddenPage.php';
exit;
}
function isForbidden() {
global $global;
if (!empty($global['isForbidden'])) {
return true;
}
return false;
}
function diskUsageBars() {
global $global;
ob_start();
include $global['systemRootPath'] . 'objects/functiondiskUsageBars.php';
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
function getDomain() {
global $global;
if (empty($_SERVER['HTTP_HOST'])) {
$parse = parse_url($global['webSiteRootURL']);
return $parse['host'];
}
$domain = $_SERVER['HTTP_HOST'];
$domain = str_replace("www.", "", $domain);
$domain = preg_match("/^\..+/", $domain) ? ltrim($domain, '.') : $domain;
return $domain;
}
/**
* It's separated by time, version, clock_seq_hi, clock_seq_lo, node, as indicated in the followoing rfc.
*
* From the IETF RFC4122:
* 8-4-4-4-12
* @return string
*/
function getDeviceID() {
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return "unknowDevice";
}
$cookieName = "yptDeviceID";
if (empty($_COOKIE[$cookieName])) {
if (empty($_GET[$cookieName])) {
$_GET[$cookieName] = uniqidV4();
}
if (empty($_SESSION[$cookieName])) {
_session_start();
$_SESSION[$cookieName] = $_GET[$cookieName];
} else {
$_GET[$cookieName] = $_SESSION[$cookieName];
}
if (!_setcookie($cookieName, $_GET[$cookieName], strtotime("+ 1 year"))) {
return "getDeviceIDError";
}
$_COOKIE[$cookieName] = $_GET[$cookieName];
return $_GET[$cookieName];
}
return $_COOKIE[$cookieName];
}
function uniqidV4() {
$randomString = openssl_random_pseudo_bytes(16);
$time_low = bin2hex(substr($randomString, 0, 4));
$time_mid = bin2hex(substr($randomString, 4, 2));
$time_hi_and_version = bin2hex(substr($randomString, 6, 2));
$clock_seq_hi_and_reserved = bin2hex(substr($randomString, 8, 2));
$node = bin2hex(substr($randomString, 10, 6));
/**
* Set the four most significant bits (bits 12 through 15) of the
* time_hi_and_version field to the 4-bit version number from
* Section 4.1.3.
* @see http://tools.ietf.org/html/rfc4122#section-4.1.3
*/
$time_hi_and_version = hexdec($time_hi_and_version);
$time_hi_and_version = $time_hi_and_version >> 4;
$time_hi_and_version = $time_hi_and_version | 0x4000;
/**
* Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
*/
$clock_seq_hi_and_reserved = hexdec($clock_seq_hi_and_reserved);
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
return sprintf('%08s-%04s-%04x-%04x-%012s', $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
}
// guid
function _setcookie($cookieName, $value, $expires = 0) {
if (empty($expires)) {
if (empty($config) || !is_object($config)) {
$config = new Configuration();
}
$expires = time() + $config->getSession_timeout();
}
if (version_compare(phpversion(), '7.3', '>=')) {
$cookie_options = array(
'expires' => $expires,
'path' => '/',
'domain' => getDomain(),
'secure' => true,
'httponly' => false,
'samesite' => 'None');
return setcookie($cookieName, $value, $cookie_options);
} else {
return setcookie($cookieName, $value, (int) $expires, "/", getDomain());
}
}
function _unsetcookie($cookieName) {
$domain = getDomain();
$expires = strtotime("-10 years");
$value = "";
_setcookie($cookieName, $value, $expires);
setcookie($cookieName, $value, (int) $expires, "/") && setcookie($cookieName, $value, (int) $expires);
setcookie($cookieName, $value, (int) $expires, "/", str_replace("www", "", $domain));
setcookie($cookieName, $value, (int) $expires, "/", "www." . $domain);
setcookie($cookieName, $value, (int) $expires, "/", "." . $domain);
setcookie($cookieName, $value, (int) $expires, "/", $domain);
setcookie($cookieName, $value, (int) $expires, "/");
setcookie($cookieName, $value, (int) $expires);
unset($_COOKIE[$cookieName]);
}
/**
* This function is not 100% but try to tell if the site is in an iFrame
* @global type $global
* @return boolean
*/
function isIframeInDifferentDomain() {
global $global;
if (!isIframe()) {
return false;
}
return isSameDomainAsMyAVideo($_SERVER['HTTP_REFERER']);
}
function isIframe() {
global $global;
if (isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe') {
return true;
}
if (empty($_SERVER['HTTP_REFERER'])) {
return false;
}
return true;
}
function getCredentialsURL() {
global $global;
return "webSiteRootURL=" . urlencode($global['webSiteRootURL']) . "&user=" . urlencode(User::getUserName()) . "&pass=" . urlencode(User::getUserPass()) . "&encodedPass=1";
}
function gotToLoginAndComeBackHere($msg) {
global $global;
if (!empty($_GET['comebackhere'])) {
return false;
}
header("Location: {$global['webSiteRootURL']}user?redirectUri=" . urlencode(getSelfURI()) . "&msg=" . urlencode($msg) . "&comebackhere=1");
exit;
}
function setAlertMessage($msg, $type = "msg") {
_session_start();
$_SESSION['YPTalertMessage'][] = array($msg, $type);
}
function setToastMessage($msg) {
setAlertMessage($msg, "toast");
}
function showAlertMessage() {
if (!empty($_SESSION['YPTalertMessage'])) {
foreach ($_SESSION['YPTalertMessage'] as $value) {
if (!empty($value[0])) {
if (empty($_GET[$value[1]])) {
$_GET[$value[1]] = array();
}
$_GET[$value[1]][] = $value[0];
}
}
_session_start();
unset($_SESSION['YPTalertMessage']);
}
$joinString = array('error', 'msg', 'success');
foreach ($joinString as $value) {
if (!empty($_GET[$value]) && is_array($_GET[$value])) {
$_GET[$value] = array_unique($_GET[$value]);
$newStr = array();
foreach ($_GET[$value] as $value2) {
if (!empty($value2)) {
$newStr[] = $value2;
}
}
$_GET[$value] = implode(" ", $newStr);
}
}
$check = array('error', 'msg', 'success', 'toast');
foreach ($check as $value) {
if (!empty($_GET[$value])) {
if (is_array($_GET[$value])) {
$newStr = array();
foreach ($_GET[$value] as $key => $value2) {
$value2 = str_replace('"', "''", $value2);
if (!empty($value2)) {
$newStr[] = $value2;
}
}
$_GET[$value] = $newStr;
} else {
$_GET[$value] = str_replace('"', "''", $_GET[$value]);
}
}
}
echo "/** showAlertMessage **/", PHP_EOL;
if (!empty($_GET['error'])) {
echo 'avideoAlertError("' . $_GET['error'] . '");';
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
if (!empty($_GET['msg'])) {
echo 'avideoAlertInfo("' . $_GET['msg'] . '");';
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
if (!empty($_GET['success'])) {
echo 'avideoAlertSuccess("' . $_GET['success'] . '");';
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
if (!empty($_GET['toast'])) {
if (!is_array($_GET['toast'])) {
$_GET['toast'] = array($_GET['toast']);
} else {
$_GET['toast'] = array_unique($_GET['toast']);
}
foreach ($_GET['toast'] as $key => $value) {
$hideAfter = strlen(strip_tags($value)) * 150;
if ($hideAfter < 3000) {
$hideAfter = 3000;
}
if ($hideAfter > 15000) {
$hideAfter = 15000;
}
echo '$.toast({
text: "' . $value . '",
hideAfter: ' . $hideAfter . ' // in milli seconds
});console.log("Toast Hide after ' . $hideAfter . '");';
}
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
echo PHP_EOL, "/** showAlertMessage END **/";
}
function getResolutionLabel($res) {
if ($res == 720) {
return "" . getResolutionText($res) . " ";
} elseif ($res == 1080) {
return "" . getResolutionText($res) . " ";
} elseif ($res == 1440) {
return "" . getResolutionText($res) . " ";
} elseif ($res == 2160) {
return "" . getResolutionText($res) . " ";
} elseif ($res == 4320) {
return "" . getResolutionText($res) . " ";
} else {
return '';
}
}
function getResolutionText($res) {
if ($res == 720) {
return "HD";
} elseif ($res == 1080) {
return "FHD";
} elseif ($res == 1440) {
return "FHD+";
} elseif ($res == 2160) {
return "4K";
} elseif ($res == 4320) {
return "8K";
} else {
return '';
}
}
// just realize the readdir is a lot faster then glob
function _glob($dir, $pattern) {
global $_glob;
if (empty($dir)) {
return array();
}
if (empty($_glob)) {
$_glob = array();
}
$name = md5($dir . $pattern);
if (isset($_glob[$name])) {
return $_glob[$name];
}
$dir = rtrim($dir, '/') . '/';
$array = array();
if ($handle = opendir($dir)) {
$count = 0;
while (false !== ($file_name = readdir($handle))) {
if (preg_match($pattern, $file_name)) {
$array[] = "{$dir}{$file_name}";
}
}
closedir($handle);
}
$_glob[$name] = $array;
return $array;
}
function globVideosDir($filename, $filesOnly = false) {
global $global;
if (empty($filename)) {
return array();
}
$cleanfilename = Video::getCleanFilenameFromFile($filename);
$pattern = "/{$cleanfilename}.*";
if (!empty($filesOnly)) {
$formats = getValidFormats();
$pattern .= ".(" . implode("|", $formats) . ")";
}
$pattern .= "/";
return _glob("{$global['systemRootPath']}videos/", $pattern);
}
function getValidFormats() {
$video = array('webm', 'mp4', 'm3u8');
$audio = array('mp3', 'ogg');
$image = array('jpg', 'gif', 'webp');
return array_merge($video, $audio, $image);
}
function isValidFormats($format) {
$format = str_replace(".", "", $format);
return in_array($format, getValidFormats());
}
function getTimerFromDates($startTime, $endTime = 0) {
if (!is_int($startTime)) {
$startTime = strtotime($startTime);
}
if (!is_int($endTime)) {
$endTime = strtotime($endTime);
}
if (empty($endTime)) {
$endTime = time();
}
$timer = abs($endTime - $startTime);
$uid = uniqid();
return " ";
}
function getServerClock() {
$id = uniqid();
$today = getdate();
$html = '00:00:00 ';
$html .= "";
return $html;
}
/**
* Xsendfile and FFMPEG are required for this feature
* @global type $global
* @param type $filepath
* @return boolean
*/
function downloadHLS($filepath) {
global $global;
if (!CustomizeUser::canDownloadVideos()) {
_error_log("downloadHLS: CustomizeUser::canDownloadVideos said NO");
return false;
}
if (!file_exists($filepath)) {
_error_log("downloadHLS: file NOT found: {$filepath}");
return false;
}
$videosDir = "{$global['systemRootPath']}videos/";
$outputfilename = str_replace($videosDir, "", $filepath);
$parts = explode("/", $outputfilename);
$resolution = Video::getResolutionFromFilename($filepath);
$outputfilename = $parts[0] . "_{$resolution}_.mp4";
$outputpath = "{$videosDir}cache/downloads/{$outputfilename}";
make_path($outputpath);
if (empty($outputfilename)) {
_error_log("downloadHLS: empty outputfilename {$outputfilename}");
return false;
}
if (!empty($_REQUEST['title'])) {
$quoted = sprintf('"%s"', addcslashes(basename($_REQUEST['title']), '"\\'));
} elseif (!empty($_REQUEST['file'])) {
$quoted = sprintf('"%s"', addcslashes(basename($_REQUEST['file']), '"\\')) . ".mp4";
} else {
$quoted = $outputfilename;
}
$filepath = escapeshellcmd($filepath);
$outputpath = escapeshellcmd($outputpath);
if (true || !file_exists($outputpath)) {
$command = get_ffmpeg() . " -allowed_extensions ALL -y -i {$filepath} -c:v copy -c:a copy -bsf:a aac_adtstoasc -strict -2 {$outputpath}";
//var_dump($outputfilename, $command, $_GET, $filepath, $quoted);exit;
exec($command . " 2>&1", $output, $return);
if (!empty($return)) {
_error_log("downloadHLS: " . implode(PHP_EOL, $output));
return false;
}
}
//var_dump($outputfilename, $command, $_GET, $filepath, $quoted);exit;
//var_dump($command, $outputpath);exit;
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . $quoted);
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("X-Sendfile: {$outputpath}");
exit;
}
function getSocialModal($videos_id, $url = "", $title = "") {
global $global;
$video['id'] = $videos_id;
$sharingUid = uniqid();
ob_start(); ?>
$contents, 'id' => $sharingUid);
}
function getCroppie(
$buttonTitle,
$callBackJSFunction,
$resultWidth,
$resultHeight,
$viewportWidth = 0,
$boundary = 25,
$viewportHeight = 0
) {
global $global;
if (empty($viewportWidth)) {
$viewportWidth = $resultWidth;
}
$zoom = 0;
if (empty($viewportHeight)) {
$zoom = ($viewportWidth / $resultWidth);
$viewportHeight = $zoom * $resultHeight;
}
$boundaryWidth = $viewportWidth + $boundary;
$boundaryHeight = $viewportHeight + $boundary;
$uid = uniqid();
ob_start();
include $global['systemRootPath'] . 'objects/functionCroppie.php';
$contents = ob_get_contents();
ob_end_clean();
$callBackJSFunction = addcslashes($callBackJSFunction, "'");
return array(
"html" => $contents,
"id" => "croppie{$uid}",
"uploadCropObject" => "uploadCrop{$uid}",
"getCroppieFunction" => "getCroppie(uploadCrop{$uid}, '{$callBackJSFunction}', {$resultWidth}, {$resultHeight});",
"createCroppie" => "createCroppie{$uid}",
"restartCroppie" => "restartCroppie{$uid}"
);
}
function saveCroppieImage($destination, $postIndex = "imgBase64") {
if (empty($_POST[$postIndex])) {
return false;
}
$fileData = base64DataToImage($_POST[$postIndex]);
return file_put_contents($destination, $fileData);
}
function get_ffmpeg($ignoreGPU = false) {
global $global;
//return 'ffmpeg -user_agent "'.getSelfUserAgent("FFMPEG").'" ';
//return 'ffmpeg -headers "User-Agent: '.getSelfUserAgent("FFMPEG").'" ';
$ffmpeg = 'ffmpeg ';
if (empty($ignoreGPU) && !empty($global['ffmpegGPU'])) {
$ffmpeg .= ' --enable-nvenc ';
}
if (!empty($global['ffmpeg'])) {
$ffmpeg = "{$global['ffmpeg']}{$ffmpeg}";
}
return $ffmpeg;
}
function isHTMLPage($url) {
if ($type = getHeaderContentTypeFromURL($url)) {
if (preg_match('/text\/html/i', $type)) {
return true;
}
}
return false;
}
function getHeaderContentTypeFromURL($url) {
if (isValidURL($url) && $type = get_headers($url, 1)["Content-Type"]) {
return $type;
}
return false;
}
diff --git a/objects/userRecoverPass.php b/objects/userRecoverPass.php
index 6ee53cf95..f579d9f5c 100644
--- a/objects/userRecoverPass.php
+++ b/objects/userRecoverPass.php
@@ -1,179 +1,179 @@
getEmail())) {
$recoverPass = md5(rand());
$recoverPass = $user->setRecoverPass($recoverPass);
if (!empty($_POST['captcha']) && $user->save()) {
require_once 'captcha.php';
$valid = Captcha::validation($_POST['captcha']);
if ($valid) {
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/PHPMailer.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/SMTP.php';
require_once $global['systemRootPath'] . 'objects/PHPMailer/src/Exception.php';
//Create a new PHPMailer instance
$mail = new PHPMailer\PHPMailer\PHPMailer;
setSiteSendMessage($mail);
//Set who the message is to be sent from
$mail->setFrom($config->getContactEmail(), $config->getWebSiteTitle());
//Set who the message is to be sent to
$mail->addAddress($user->getEmail());
//Set the subject line
$mail->Subject = 'Recover Pass from ' . $config->getWebSiteTitle();
$msg = __("You asked for a recover link, click on the provided link") . " " . __("Reset password") . " ";
$mail->msgHTML($msg);
//send the message, check for errors
if (!$mail->send()) {
$obj->error = __("Message could not be sent") . " " . $mail->ErrorInfo;
} else {
$obj->success = __("Message sent");
}
} else {
$obj->error = __("Your code is not valid");
}
} else {
$obj->error = __("Recover password could not be saved!");
}
} else {
$obj->error = __("You do not have an e-mail");
}
die(json_encode($obj));
} else {
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
getRecoverPass() != $_GET['recoverpass']) {
?>
- getWebSiteTitle(); ?> :: VAST
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/API/info.php b/plugin/API/info.php
index 3c8fb5fd3..497a6a6fc 100644
--- a/plugin/API/info.php
+++ b/plugin/API/info.php
@@ -1,111 +1,111 @@
- getWebSiteTitle(); ?> :: API
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
$method_name) {
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) {
unset($class_methods[$key]);
}
}
usort($class_methods, function ($a, $b) {
if (!preg_match("/(get|set)_api_(.*)/", $a, $matchesA)) {
return 0;
}
if (!preg_match("/(get|set)_api_(.*)/", $b, $matchesB)) {
return 0;
}
return strcasecmp($matchesA[2], $matchesB[2]);
});
?>
Upload a Video
For more detailed instructions please read this
Your HTML Form should looks like this. The user and the pass values on the action URL will be the video owner
';
echo htmlentities($frm);
?>
You can get notified for the new video uploads with the Webhook in the Notification plugin, Check here for more details
-alt">
getMethod($method_name)->getDocComment();
$comment = str_replace(array('{webSiteRootURL}', '{getOrSet}', '{APIName}', '{APISecret}'), array($global['webSiteRootURL'], $matches[1], $matches[2], $obj->APISecret), $comment);
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2);
//var_dump($match2[0]);
$link = "" . htmlentities($match2[0][0]) . " ";
$comment = str_replace(array($match2[0][0]," *"), array($link,"*"), $comment);
echo ($comment);
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}
?>
diff --git a/plugin/Audit/page/editor.php b/plugin/Audit/page/editor.php
index d5f778d10..2b24d78cb 100644
--- a/plugin/Audit/page/editor.php
+++ b/plugin/Audit/page/editor.php
@@ -1,85 +1,85 @@
- getWebSiteTitle(); ?> :: Audit
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
Class
Method
Statement
Format
Values
Created
User
IP
Class
Method
Statement
Format
Values
Created
User
IP
diff --git a/plugin/BlockonomicsYPT/invoice.php b/plugin/BlockonomicsYPT/invoice.php
index 96224fe18..44183c454 100644
--- a/plugin/BlockonomicsYPT/invoice.php
+++ b/plugin/BlockonomicsYPT/invoice.php
@@ -1,134 +1,134 @@
setUpPayment($_GET['value']);
$order = new BlockonomicsOrder($order_id);
?>
- getWebSiteTitle(); ?> :: Audit
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
Order#: getId()); ?>
To pay, send exact amount of BTC to the given address
Amount
getFormatedBits(); ?> BTC ⇌ getTotal_value(); ?> getCurrency(); ?>
Payment Details:
Payment Expired
Payment Error
Unconfirmed
Partially Confirmed
Confirmed
Received : getFormatedBits_payed(); ?>
BTC
Transaction :
diff --git a/plugin/BulkEmbed/search.php b/plugin/BulkEmbed/search.php
index 9287a6a49..7dca4630e 100644
--- a/plugin/BulkEmbed/search.php
+++ b/plugin/BulkEmbed/search.php
@@ -1,449 +1,449 @@
- getWebSiteTitle(); ?> :: Bulk Embed
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/CloneSite/index.php b/plugin/CloneSite/index.php
index 8a058b1df..14b69d48d 100644
--- a/plugin/CloneSite/index.php
+++ b/plugin/CloneSite/index.php
@@ -1,164 +1,164 @@
- getWebSiteTitle(); ?> :: VAST
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/CombineSites/page/editor.php b/plugin/CombineSites/page/editor.php
index f049637c3..fcd3ca067 100644
--- a/plugin/CombineSites/page/editor.php
+++ b/plugin/CombineSites/page/editor.php
@@ -1,606 +1,606 @@
- getWebSiteTitle(); ?> :: Combine Sites
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
' . __("Waiting connection approval") . '
' . __("Connected") . '
' . __("Connection pre approved") . '
';
return $str;
}
function combineEditorGiveLabels($name, $id) {
$str = '
' . __("Request to approve connection") . '
' . __("Connected") . '
' . __("Pre approved connection") . '
';
return $str;
}
?>
\ No newline at end of file
diff --git a/plugin/CustomizeAdvanced/confirmRating.php b/plugin/CustomizeAdvanced/confirmRating.php
index 84fff84c7..70b982b63 100644
--- a/plugin/CustomizeAdvanced/confirmRating.php
+++ b/plugin/CustomizeAdvanced/confirmRating.php
@@ -1,95 +1,95 @@
poster;
if (!empty($images->posterPortrait) && strpos($images->posterPortrait, 'notfound_portrait') === false) {
$img = $images->posterPortrait;
}
$imgw = 1280;
$imgh = 720;
?>
- getWebSiteTitle(); ?> :: Confirm Rating
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
" />
- getWebSiteTitle(); ?>" />
" />
diff --git a/plugin/CustomizeUser/confirmVideoPassword.php b/plugin/CustomizeUser/confirmVideoPassword.php
index 9b52080b8..7d6c5ac87 100644
--- a/plugin/CustomizeUser/confirmVideoPassword.php
+++ b/plugin/CustomizeUser/confirmVideoPassword.php
@@ -1,112 +1,112 @@
poster;
if (!empty($images->posterPortrait) && strpos($images->posterPortrait, 'notfound_portrait') === false) {
$img = $images->posterPortrait;
}
$imgw = 1280;
$imgh = 720;
?>
- getWebSiteTitle(); ?> :: Confirm Rating
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
" />
- getWebSiteTitle(); ?>" />
" />
diff --git a/plugin/Gallery/view/topLogic.php b/plugin/Gallery/view/topLogic.php
index be3366866..b65a5ed2e 100644
--- a/plugin/Gallery/view/topLogic.php
+++ b/plugin/Gallery/view/topLogic.php
@@ -1,73 +1,87 @@
getWebSiteTitle();
+$siteTitle = array();
$obj = AVideoPlugin::getObjectData("Gallery");
if (!empty($_GET['type'])) {
if ($_GET['type'] == 'audio') {
$_SESSION['type'] = 'audio';
} else if ($_GET['type'] == 'video') {
$_SESSION['type'] = 'video';
} else {
unset($_SESSION['type']);
}
}
require_once $global['systemRootPath'] . 'objects/category.php';
$currentCat;
if (!empty($_GET['catName'])) {
$currentCat = Category::getCategoryByName($_GET['catName']);
- $siteTitle = "{$currentCat['name']}";
+ array_push($siteTitle, $currentCat['name']);
}
require_once $global['systemRootPath'] . 'objects/video.php';
$orderString = "";
if ($obj->sortReverseable) {
if (strpos($_SERVER['REQUEST_URI'], "?") != false) {
$orderString = $_SERVER['REQUEST_URI'] . "&";
} else {
$orderString = $_SERVER['REQUEST_URI'] . "/?";
}
$orderString = str_replace("&&", "&", $orderString);
$orderString = str_replace("//", "/", $orderString);
}
$video = Video::getVideo("", "viewable", !$obj->hidePrivateVideos, false, true);
if (empty($video)) {
$video = Video::getVideo("", "viewable", !$obj->hidePrivateVideos, true);
}
if (empty($_GET['page'])) {
$_GET['page'] = 1;
} else {
$_GET['page'] = intval($_GET['page']);
}
$total = 0;
$totalPages = 0;
$url = '';
$args = '';
$metaDescription = "";
if(!empty($video)){
if (strpos($_SERVER['REQUEST_URI'], "?") != false) {
$args = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "?"), strlen($_SERVER['REQUEST_URI']));
}
if (strpos($_SERVER['REQUEST_URI'], "/cat/") === false) {
$url = $global['webSiteRootURL'] . "page/";
} else {
$url = $global['webSiteRootURL'] . "cat/" . $video['clean_category'] . "/page/";
}
$contentSearchFound = false;
- // for SEO to not rise an error of duplicated title or description of same pages with and without last slash
- $siteTitle .= getSEOComplement();
- $metaDescription = " ".$video['id'];
- // make sure the www has a different title and description than non www
- if(strrpos($_SERVER['HTTP_HOST'], 'www.')=== false){
- $siteTitle .= ": ".__("Home");
- $metaDescription .= ": ".__("Home");
- }
-}
\ No newline at end of file
+
+ array_push($siteTitle, __("Home"));
+
+ // don't add a prefix for SEO, it's already handled here below by the implode() func
+ $seoComplement = getSEOComplement(array(
+ "addAutoPrefix" => false,
+ "addCategory" => false
+ ));
+ if (!empty($seoComplement)) {
+ array_push($siteTitle, $seoComplement);
+ }
+
+ $metaDescription = $video['id'];
+} else {
+ array_push($siteTitle, __("Video Not Available"));
+ array_push($siteTitle, __("Home"));
+
+ $metaDescription = __("Video Not Available");
+}
+array_push($siteTitle, $config->getWebSiteTitle());
+$metaDescription .= $config->getPageTitleSeparator() . __("Home");
+
+$siteTitle = implode($config->getPageTitleSeparator(), $siteTitle);
diff --git a/plugin/Live/index.php b/plugin/Live/index.php
index 95c1db98d..4ede56896 100644
--- a/plugin/Live/index.php
+++ b/plugin/Live/index.php
@@ -1,298 +1,298 @@
getDataObject();
if (!empty($_GET['c'])) {
$user = User::getChannelOwner($_GET['c']);
if (!empty($user)) {
$_GET['u'] = $user['user'];
}
}
if (!empty($_GET['c'])) {
$user = User::getChannelOwner($_GET['c']);
if ($user['status'] !== 'a') {
header("Location: {$global['webSiteRootURL']}");
}
}
if (!empty($_GET['u']) && !empty($_GET['embedv2'])) {
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbededV2.php';
exit;
} else if (!empty($_GET['u']) && !empty($_GET['embed'])) {
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbeded.php';
exit;
} else if (!empty($_GET['u'])) {
include $global['systemRootPath'] . 'plugin/Live/view/modeYoutubeLive.php';
exit;
} else if (!User::isLogged()) {
gotToLoginAndComeBackHere("");
exit;
} else if (!User::canStream()) {
forbiddenPage(__($obj->streamDeniedMsg));
}
require_once $global['systemRootPath'] . 'objects/userGroups.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
$users_id = User::getId();
if (!empty($_GET['users_id']) && User::isAdmin()) {
$users_id = intval($_GET['users_id']);
}
// if user already have a key
$trasnmition = LiveTransmition::createTransmitionIfNeed($users_id);
if (!empty($_GET['resetKey'])) {
LiveTransmition::resetTransmitionKey($users_id);
header("Location: {$global['webSiteRootURL']}plugin/Live/");
exit;
}
$aspectRatio = "16:9";
$vjsClass = "vjs-16-9";
$trans = new LiveTransmition($trasnmition['id']);
$groups = $trans->getGroups();
//check if channel name exists
$channelName = User::getUserChannelName();
if (empty($channelName)) {
$channelName = uniqid();
$user = new User($users_id);
$user->setChannelName($channelName);
$user->save();
}
$col1Class = "col-md-12 col-lg-12";
$col2Class = "hidden";
$chat2 = AVideoPlugin::getObjectDataIfEnabled("Chat2");
if (!empty($chat2) && !empty($chat2->useStaticLayout)) {
$col1Class = "col-md-8 col-lg-8";
$col2Class = "col-md-4 col-lg-4";
}
?>
- - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
useLiveServers) {
$activeServerFound = true;
?>
$value) {
$active = "";
if (isset($_REQUEST['live_servers_id'])) {
if ($_REQUEST['live_servers_id'] == $value['id']) {
$activeServerFound = true;
$active = "active";
}
} else if ($key == 0) {
$_REQUEST['live_servers_id'] = $value['id'];
$activeServerFound = true;
$active = "active";
}
?>
Edit Live Servers
getChat($trasnmition['key']);
?>
diff --git a/plugin/Live/view/Live_restreams/index.php b/plugin/Live/view/Live_restreams/index.php
index aaf3beed4..a69601499 100644
--- a/plugin/Live/view/Live_restreams/index.php
+++ b/plugin/Live/view/Live_restreams/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: Live
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Live/view/Live_servers/index.php b/plugin/Live/view/Live_servers/index.php
index 38a972cef..47717823b 100644
--- a/plugin/Live/view/Live_servers/index.php
+++ b/plugin/Live/view/Live_servers/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: Live
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Live/view/editor.php b/plugin/Live/view/editor.php
index f049cca0c..86b2539e6 100644
--- a/plugin/Live/view/editor.php
+++ b/plugin/Live/view/editor.php
@@ -1,52 +1,52 @@
- getWebSiteTitle(); ?> :: Live
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Live/view/modeYoutubeLive.php b/plugin/Live/view/modeYoutubeLive.php
index 09b56013d..67e182f28 100644
--- a/plugin/Live/view/modeYoutubeLive.php
+++ b/plugin/Live/view/modeYoutubeLive.php
@@ -1,223 +1,223 @@
userCanSeeTransmition()) {
forbiddenPage("You are not allowed see this streaming");
}
$uuid = LiveTransmition::keyNameFix($livet['key']);
$u = new User(0, $_GET['u'], false);
$user_id = $u->getBdId();
$video['users_id'] = $user_id;
$subscribe = Subscribe::getButton($user_id);
$name = $u->getNameIdentificationBd();
$name = "{$name} " . User::getEmailVerifiedIcon($user_id) . " ";
$liveTitle = $livet['title'];
$liveDescription = $livet['description'];
$liveImg = User::getPhoto($user_id);
if (!empty($_REQUEST['playlists_id_live'])) {
$liveTitle = PlayLists::getNameOrSerieTitle($_REQUEST['playlists_id_live']);
$liveDescription = PlayLists::getDescriptionIfIsSerie($_REQUEST['playlists_id_live']);
$liveImg = PlayLists::getImage($_REQUEST['playlists_id_live']);
}
$video['creator'] = '';
$img = "{$global['webSiteRootURL']}plugin/Live/getImage.php?u={$_GET['u']}&format=jpg";
$imgw = 640;
$imgh = 360;
$liveDO = AVideoPlugin::getObjectData("Live");
$video['type'] = 'video';
AVideoPlugin::getModeYouTubeLive($user_id);
$isCompressed = AVideoPlugin::loadPluginIfEnabled('TheaterButton') && TheaterButton::isCompressed();
$sideAd = getAdsSideRectangle();
$modeYoutubeBottomClass1 = "col-sm-7 col-md-7 col-lg-6";
$modeYoutubeBottomClass2 = "col-sm-5 col-md-5 col-lg-4 ";
if (empty($sideAd) && !AVideoPlugin::loadPluginIfEnabled("Chat2")) {
$modeYoutubeBottomClass1 = "col-sm-12 col-md-12 col-lg-10";
$modeYoutubeBottomClass2 = "hidden ";
}
?>
- - - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . __("Live") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
- getWebSiteTitle(); ?>" />
" />
diff --git a/plugin/LiveChat/index.php b/plugin/LiveChat/index.php
index 140b175c1..6fabb7c9f 100644
--- a/plugin/LiveChat/index.php
+++ b/plugin/LiveChat/index.php
@@ -1,40 +1,40 @@
- Live - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
LiveChat uses a SSL connection
If you are using Apache web server (2.4 or above), enable these modules in httpd.conf file :
mod_proxy.so
mod_proxy_wstunnel.so
Add this setting to your httpd.conf file
ProxyPass /wss/ ws://127.0.0.1:8888/
Restart Apache web server and make sure that your Ratchet worker (web socket connection) is open before applying the settings (telnet hostname port).
diff --git a/plugin/LiveLinks/index.php b/plugin/LiveLinks/index.php
index 746c7740e..931c957e0 100644
--- a/plugin/LiveLinks/index.php
+++ b/plugin/LiveLinks/index.php
@@ -1,32 +1,32 @@
canAddLinks()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
}
?>
- getWebSiteTitle(); ?> :: Live Links
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/LiveLinks/view/Live.php b/plugin/LiveLinks/view/Live.php
index beb1d07ee..c8a752809 100644
--- a/plugin/LiveLinks/view/Live.php
+++ b/plugin/LiveLinks/view/Live.php
@@ -1,191 +1,191 @@
getType() == 'logged_only' && !User::isLogged()) {
die('Link for logged only');
}
$uuid = $_GET['link'];
$t['users_id'] = $liveLink->getUsers_id();
$t['title'] = $liveLink->getTitle();
$t['link'] = $liveLink->getLink();
$t['description'] = $liveLink->getDescription();
$u = new User($t['users_id']);
$user_id = $u->getBdId();
$subscribe = Subscribe::getButton($user_id);
$name = $u->getNameIdentificationBd();
$name = "{$name} " . User::getEmailVerifiedIcon($user_id) . " ";
$video['creator'] = '';
$video['type'] = "liveLink";
$img = "{$global['webSiteRootURL']}plugin/LiveLinks/getImage.php?link={$_GET['link']}&format=jpg";
$imgw = 640;
$imgh = 360;
if (!empty($_GET['embed'])) {
include $global['systemRootPath'] . 'plugin/LiveLinks/view/videoEmbeded.php';
return false;
}
$isCompressed = AVideoPlugin::loadPluginIfEnabled('TheaterButton') && TheaterButton::isCompressed();
$sideAd = getAdsSideRectangle();
$modeYoutubeBottomClass1 = "col-sm-7 col-md-7 col-lg-6";
$modeYoutubeBottomClass2 = "col-sm-5 col-md-5 col-lg-4 ";
if (empty($sideAd) && !AVideoPlugin::loadPluginIfEnabled("Chat2")) {
$modeYoutubeBottomClass1 = "col-sm-12 col-md-12 col-lg-10";
$modeYoutubeBottomClass2 = "hidden ";
}
?>
- - - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . __("Live Links") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
- getWebSiteTitle(); ?>" />
" />
getChat($uuid);
}
?>
diff --git a/plugin/LoginControl/View/Users_login_history/index.php b/plugin/LoginControl/View/Users_login_history/index.php
index 6f1592bc7..c8e7f7eb4 100644
--- a/plugin/LoginControl/View/Users_login_history/index.php
+++ b/plugin/LoginControl/View/Users_login_history/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: LoginControl
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/LoginControl/View/editor.php b/plugin/LoginControl/View/editor.php
index 2fc2377ba..2174d3bdb 100644
--- a/plugin/LoginControl/View/editor.php
+++ b/plugin/LoginControl/View/editor.php
@@ -1,46 +1,46 @@
- getWebSiteTitle(); ?> :: LoginControl
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/View/Meet_join_log/index.php b/plugin/Meet/View/Meet_join_log/index.php
index c85b34a56..9973eddf2 100644
--- a/plugin/Meet/View/Meet_join_log/index.php
+++ b/plugin/Meet/View/Meet_join_log/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: Meet
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/View/Meet_schedule/index.php b/plugin/Meet/View/Meet_schedule/index.php
index c85b34a56..9973eddf2 100644
--- a/plugin/Meet/View/Meet_schedule/index.php
+++ b/plugin/Meet/View/Meet_schedule/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: Meet
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/View/Meet_schedule_has_users_groups/index.php b/plugin/Meet/View/Meet_schedule_has_users_groups/index.php
index c85b34a56..9973eddf2 100644
--- a/plugin/Meet/View/Meet_schedule_has_users_groups/index.php
+++ b/plugin/Meet/View/Meet_schedule_has_users_groups/index.php
@@ -1,29 +1,29 @@
- getWebSiteTitle(); ?> :: Meet
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/View/editor.php b/plugin/Meet/View/editor.php
index ead776da2..d8c21f8f8 100644
--- a/plugin/Meet/View/editor.php
+++ b/plugin/Meet/View/editor.php
@@ -1,58 +1,58 @@
- getWebSiteTitle(); ?> :: Meet
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/checkServers.php b/plugin/Meet/checkServers.php
index 576ed616c..cb1b4ea31 100644
--- a/plugin/Meet/checkServers.php
+++ b/plugin/Meet/checkServers.php
@@ -1,396 +1,396 @@
setDataObjectParameter("server->value", preg_replace("/[^0-1a-z.]/i", "", $_GET['newServer']));
}
$m = AVideoPlugin::loadPlugin("Meet");
$emptyObject = $m->getEmptyDataObject();
$timeouts = 2000;
?>
- - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
server->type as $key => $value) {
if ($key == "custom") {
?>
{$value} ({$obj->CUSTOM_JITSI_DOMAIN}) ";
if ($obj->server->value !== $key) {
?>
{$value} ";
if ($obj->server->value !== $key) {
?>
Download Speed
Upload Speed
Response Time
Sites Active
Streamers Services
Before Change the server make sure you do not have any meeting running.
Other users may not able to connect after you change it.
Higher grade, means the server is better for a meeting.
diff --git a/plugin/Meet/confirmMeetPassword.php b/plugin/Meet/confirmMeetPassword.php
index 3a991402f..315dad34b 100644
--- a/plugin/Meet/confirmMeetPassword.php
+++ b/plugin/Meet/confirmMeetPassword.php
@@ -1,105 +1,105 @@
getUsers_id());
$photo = User::getPhoto($meet->getUsers_id());
?>
- getWebSiteTitle(); ?> :: Confirm Meet Password
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Meet/index.php b/plugin/Meet/index.php
index 99abc2c32..31e5b65e6 100644
--- a/plugin/Meet/index.php
+++ b/plugin/Meet/index.php
@@ -1,212 +1,212 @@
setDataObjectParameter("server->value", preg_replace("/[^0-1a-z.]/i", "", $_GET['newServer']));
}
?>
- - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Permissions/View/Users_groups_permissions/index.php b/plugin/Permissions/View/Users_groups_permissions/index.php
index 116fe4551..506594f55 100644
--- a/plugin/Permissions/View/Users_groups_permissions/index.php
+++ b/plugin/Permissions/View/Users_groups_permissions/index.php
@@ -1,29 +1,29 @@
-
getWebSiteTitle(); ?> :: Permissions
+
getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/Permissions/View/editor.php b/plugin/Permissions/View/editor.php
index 3665bd154..fc6c14a9e 100644
--- a/plugin/Permissions/View/editor.php
+++ b/plugin/Permissions/View/editor.php
@@ -1,46 +1,46 @@
-
getWebSiteTitle(); ?> :: Permissions
+
getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/PlayLists/View/Playlists_schedules/index.php b/plugin/PlayLists/View/Playlists_schedules/index.php
index 3353395fe..7bab9500e 100644
--- a/plugin/PlayLists/View/Playlists_schedules/index.php
+++ b/plugin/PlayLists/View/Playlists_schedules/index.php
@@ -1,29 +1,29 @@
-
getWebSiteTitle(); ?> :: PlayLists
+
getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/PlayLists/View/editor.php b/plugin/PlayLists/View/editor.php
index 9c5ae008e..47715446e 100644
--- a/plugin/PlayLists/View/editor.php
+++ b/plugin/PlayLists/View/editor.php
@@ -1,46 +1,46 @@
-
getWebSiteTitle(); ?> :: PlayLists
+
getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/PlayLists/epg.php b/plugin/PlayLists/epg.php
index 12efa2985..c3b131c30 100644
--- a/plugin/PlayLists/epg.php
+++ b/plugin/PlayLists/epg.php
@@ -1,33 +1,33 @@
-
EPG :: getWebSiteTitle(); ?>
+
getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
' . __("Now Playing") . '
';
//include_once $global['systemRootPath'] . 'plugin/PlayLists/epg.html.php';
include_once $global['systemRootPath'] . 'plugin/PlayLists/epg.day.php';
echo '
';
?>
diff --git a/plugin/PlayLists/player.php b/plugin/PlayLists/player.php
index 803226d4b..f9973919e 100644
--- a/plugin/PlayLists/player.php
+++ b/plugin/PlayLists/player.php
@@ -1,360 +1,360 @@
src = $images->thumbsJpg;
$thumbnail = array($src);
$playListSources = array();
foreach ($sources as $value2) {
if ($value2['type'] !== 'video' && $value2['type'] !== 'audio') {
continue;
}
$playListSources[] = new playListSource($value2['url'], $value['type'] === 'embed');
}
if (empty($playListSources)) {
continue;
}
$playListData[] = new PlayListElement($value['title'], $value['description'], $value['duration'], $playListSources, $thumbnail, $images->poster, parseDurationToSeconds(@$externalOptions->videoStartSeconds), $value['cre'], $value['likes'], $value['views_count'], $value['videos_id']);
}
$video = PlayLists::isPlayListASerie($_GET['playlists_id']);
if (!empty($video['id'])) {
AVideoPlugin::getEmbed($video['id']);
}
?>
- getName(); ?> :: getWebSiteTitle(); ?>
+ getName() . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
showChannelBannerOnModeYoutube)) {
?>
showAdsenseBannerOnTop)) {
?>
getAutoplay() && false) { // disable it for now ?>
autoplay="true"
muted="muted"
preload="auto"
controls class="embed-responsive-item video-js vjs-default-skin vjs-big-play-centered" id="mainVideo"
data-setup='{"techOrder": ["youtube","html5"]}'>
"/>
doNotDisplayViews)) {
?>
>
! videoNotFoundText->value) ? __("We have not found any videos or audios to show") : $advancedCustom->videoNotFoundText->value; ?>.
diff --git a/plugin/PlayerSkins/playerSample.php b/plugin/PlayerSkins/playerSample.php
index c11a45801..18004946a 100644
--- a/plugin/PlayerSkins/playerSample.php
+++ b/plugin/PlayerSkins/playerSample.php
@@ -1,64 +1,64 @@
- getWebSiteTitle(); ?> :: Player Sample
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/PredefinedCategory/page/editor.php b/plugin/PredefinedCategory/page/editor.php
index 65242dc85..302d9d264 100644
--- a/plugin/PredefinedCategory/page/editor.php
+++ b/plugin/PredefinedCategory/page/editor.php
@@ -1,307 +1,307 @@
- getWebSiteTitle(); ?> :: Predefined Category
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
Here you can choose the default category whenever a video is submitted to your site.
Select a user then choose the defaul category.
Here you can choose the default user group.
When ever you upload a new video this video will be exclusive for the
user groups you selected.
Leave it blank to be public by default
diff --git a/plugin/StripeYPT/listSubscriptions.php b/plugin/StripeYPT/listSubscriptions.php
index 1278d9596..ee8bee47c 100644
--- a/plugin/StripeYPT/listSubscriptions.php
+++ b/plugin/StripeYPT/listSubscriptions.php
@@ -1,143 +1,143 @@
cancelSubscriptions($_GET['subscription_id']);
}
?>
- getWebSiteTitle(); ?> :: Stripe Subscription
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
getAllSubscriptions();
foreach ($subs->data as $value) {
$users_id = $value->metadata->users_id;
$plans_id = $value->metadata->plans_id;
$title = "";
$body = "";
$buttonClass = "danger";
if (!empty($users_id)) {
$user = new User($users_id);
if (!empty($user)) {
$title .= $user->getName() . " (" . $user->getEmail() . ")";
}
} else {
$title .= "User ID Not found";
}
if (AVideoPlugin::isEnabledByName("Subscription")) {
if (!empty($plans_id)) {
$plan = new SubscriptionPlansTable($plans_id);
if (!empty($plan)) {
$title .= " [" . $plan->getName() . "]";
$row = SubscriptionTable::getSubscription($users_id, $plans_id);
if (!empty($row)) {
$buttonClass = "success";
}
}
} else {
$title .= " [Plan ID Not found]";
}
}
$body .= "
Created in: " . date("Y-m-d", $value->created);
foreach ($value->items->data as $value2) {
$body .= "
Plan: " . $value2->plan->nickname;
$body .= "
Value: " . StripeYPT::addDot($value2->plan->amount) . " " . $value2->plan->currency;
$body .= "
Interval: each " . $value2->plan->interval_count . " " . $value2->plan->interval;
}
?>
getAllSubscriptions('trialing');
foreach ($subs->data as $value) {
$users_id = $value->metadata->users_id;
$plans_id = $value->metadata->plans_id;
$title = "";
$body = "";
$buttonClass = "danger";
if (!empty($users_id)) {
$user = new User($users_id);
if (!empty($user)) {
$title .= $user->getName() . " (" . $user->getEmail() . ")";
}
} else {
$title .= "User ID Not found";
}
if (AVideoPlugin::isEnabledByName("Subscription")) {
if (!empty($plans_id)) {
$plan = new SubscriptionPlansTable($plans_id);
if (!empty($plan)) {
$title .= " [" . $plan->getName() . "]";
$row = SubscriptionTable::getSubscription($users_id, $plans_id);
if (!empty($row)) {
$buttonClass = "success";
}
}
} else {
$title .= " [Plan ID Not found]";
}
}
$body .= "
Created in: " . date("Y-m-d", $value->created);
foreach ($value->items->data as $value2) {
$body .= "
Plan: " . $value2->plan->nickname;
$body .= "
Value: " . StripeYPT::addDot($value2->plan->amount) . " " . $value2->plan->currency;
$body .= "
Interval: each " . $value2->plan->interval_count . " " . $value2->plan->interval;
}
?>
diff --git a/plugin/TopMenu/index.php b/plugin/TopMenu/index.php
index 63b5a63c8..17c82fa90 100644
--- a/plugin/TopMenu/index.php
+++ b/plugin/TopMenu/index.php
@@ -1,56 +1,56 @@
getUrl();
?>
- getWebSiteTitle(); ?> :: getTitle(); ?>
+ getTitle() . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/TopMenu/page/editor.php b/plugin/TopMenu/page/editor.php
index 8024f20e5..72b552ab1 100644
--- a/plugin/TopMenu/page/editor.php
+++ b/plugin/TopMenu/page/editor.php
@@ -1,569 +1,569 @@
- getWebSiteTitle(); ?> :: Top Menu
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
Text
diff --git a/plugin/VideoLogoOverlay/page/editor.php b/plugin/VideoLogoOverlay/page/editor.php
index 099139610..eae47f57a 100644
--- a/plugin/VideoLogoOverlay/page/editor.php
+++ b/plugin/VideoLogoOverlay/page/editor.php
@@ -1,179 +1,179 @@
- getWebSiteTitle(); ?> :: Customize
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
Create an Video Overlay Button
diff --git a/plugin/VideoTags/index.php b/plugin/VideoTags/index.php
index ef5d45525..87b56f2c4 100644
--- a/plugin/VideoTags/index.php
+++ b/plugin/VideoTags/index.php
@@ -1,27 +1,27 @@
- getWebSiteTitle(); ?> :: Tags
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/WWBN/page/info.php b/plugin/WWBN/page/info.php
index a64dfd7bd..511ed279e 100644
--- a/plugin/WWBN/page/info.php
+++ b/plugin/WWBN/page/info.php
@@ -1,155 +1,155 @@
- getWebSiteTitle(); ?> :: WWBN
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
INSTRUCTION
Step #1 - Setup
Enable "WWBN" plugin and Create an Account.
Step #2 - Account Verified
Wait until you received an email similar to this one. Then you can login from here to submit/update your index or go back to your "WWBN" plugin then login through the setup button.
Step #3 - Signin and Submit an Index
For adding new index; for the first time the data from your platform will be automatically generated and if you already have an existing data you need to type your other platform url then click generate.
Step #4 - Verify Index
Click the unverified/verified button of your index, A form to input your validation token will pop-up or an alert message that your index is already verified.
Step #5 - Updating Index
Click the edit button of your index, change/update the data for the allowed/editable field then click update button to appy changes.
Step #5 - Deactivating/Re-activating Index
Changing status of your index to inreview or inactive
Additional Info - Index data
Display engine name with your platform icon.
Display verify or unverified, Click the to unverified to show form to verify your Index so that the admin can assign your it to an affiliate.
Inreview = Pending for approval, Inactive = Indexing is not avaible for assigning to an Affiliate or Disapproved by the admin due to some contents conflict, Approved = Index is ready/avialable to be assign to an Affiliate but still need verified.
The Content Type of your Platform.
Edit button, redirect to update form to edit the content type or country restriction.
Link button, redirect to your platform home page.
Deactivate = To set the status to inactive, Re-activate = To set/resubmit your index to be index to an affiliate
Display list of Affiliate/s.
diff --git a/plugin/WWBN/page/wwbn_signup.php b/plugin/WWBN/page/wwbn_signup.php
index 86cb96883..2dcb17550 100644
--- a/plugin/WWBN/page/wwbn_signup.php
+++ b/plugin/WWBN/page/wwbn_signup.php
@@ -1,38 +1,38 @@
- getWebSiteTitle(); ?> :: WWBN
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/YPTWallet/view/addFunds.php b/plugin/YPTWallet/view/addFunds.php
index 4d9117f8b..44e9dfa60 100644
--- a/plugin/YPTWallet/view/addFunds.php
+++ b/plugin/YPTWallet/view/addFunds.php
@@ -1,97 +1,97 @@
getDataObject();
if (!empty($paypal)) {
$paypalObj = $paypal->getDataObject();
}
$options = json_decode($obj->addFundsOptions);
unset($_SESSION['addFunds_Success']);
unset($_SESSION['addFunds_Fail']);
?>
- Add Funds
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
add_funds_text ?>
add_funds_success_fail;
break;
case "success":
$text = $obj->add_funds_success_success;
$class = "success";
break;
case "cancel":
$text = $obj->add_funds_success_cancel;
$class = "warning";
break;
}
?>
currency_symbol; ?> currency; ?>
currency_symbol; ?> currency; ?>
getAvailablePayments();
?>
diff --git a/plugin/YPTWallet/view/adminManageWallets.php b/plugin/YPTWallet/view/adminManageWallets.php
index a4913dc69..18340ae6a 100644
--- a/plugin/YPTWallet/view/adminManageWallets.php
+++ b/plugin/YPTWallet/view/adminManageWallets.php
@@ -1,153 +1,153 @@
getDataObject();
?>
- Support Author
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/YPTWallet/view/configuration.php b/plugin/YPTWallet/view/configuration.php
index 19f91208c..8978e42c0 100644
--- a/plugin/YPTWallet/view/configuration.php
+++ b/plugin/YPTWallet/view/configuration.php
@@ -1,74 +1,74 @@
getDataObject();
$wallet = new Wallet(0);
$wallet->setUsers_id(User::getId());
?>
- Add Funds
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/YPTWallet/view/history.php b/plugin/YPTWallet/view/history.php
index 4f3180097..5ae68a85d 100644
--- a/plugin/YPTWallet/view/history.php
+++ b/plugin/YPTWallet/view/history.php
@@ -1,162 +1,162 @@
- Support Author
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/YPTWallet/view/manualAddFunds.php b/plugin/YPTWallet/view/manualAddFunds.php
index 9c564dcab..5b2970604 100644
--- a/plugin/YPTWallet/view/manualAddFunds.php
+++ b/plugin/YPTWallet/view/manualAddFunds.php
@@ -1,120 +1,120 @@
getDataObject();
$options = json_decode($obj->addFundsOptions);
?>
- Add Funds
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
add_funds_text ?>
add_funds_success_fail;
break;
case "success":
$text = $obj->add_funds_success_success;
$class = "success";
break;
case "cancel":
$text = $obj->add_funds_success_cancel;
$class = "warning";
break;
}
?>
currency_symbol; ?> currency; ?>
currency_symbol; ?> currency; ?>
manualAddFundsPageButton; ?>
diff --git a/plugin/YPTWallet/view/manualWithdrawFunds.php b/plugin/YPTWallet/view/manualWithdrawFunds.php
index 14b45a947..125355f03 100644
--- a/plugin/YPTWallet/view/manualWithdrawFunds.php
+++ b/plugin/YPTWallet/view/manualWithdrawFunds.php
@@ -1,119 +1,119 @@
getDataObject();
$options = json_decode($obj->withdrawFundsOptions);
?>
- Add Funds
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
withdraw_funds_text ?>
add_funds_success_fail;
break;
case "success":
$text = $obj->add_funds_success_success;
$class = "success";
break;
case "cancel":
$text = $obj->add_funds_success_cancel;
$class = "warning";
break;
}
?>
currency_symbol; ?> currency; ?>
currency_symbol; ?> currency; ?>
manualWithdrawFundsPageButton; ?>
diff --git a/plugin/YPTWallet/view/pendingRequests.php b/plugin/YPTWallet/view/pendingRequests.php
index ba5a69f2c..afedf4428 100644
--- a/plugin/YPTWallet/view/pendingRequests.php
+++ b/plugin/YPTWallet/view/pendingRequests.php
@@ -1,116 +1,116 @@
- Support Author
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/plugin/YPTWallet/view/transferFunds.php b/plugin/YPTWallet/view/transferFunds.php
index 3a9108d46..b76b8a036 100644
--- a/plugin/YPTWallet/view/transferFunds.php
+++ b/plugin/YPTWallet/view/transferFunds.php
@@ -1,201 +1,201 @@
- Transfer Funds
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
transfer_funds_text ?>
transfer_funds_success_fail;
break;
case "success":
$text = $obj->transfer_funds_success_success;
$class = "success";
break;
}
?>
{identification}
diff --git a/view/about.php b/view/about.php
index ebbe9e90a..236d554b3 100644
--- a/view/about.php
+++ b/view/about.php
@@ -1,85 +1,85 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
getAbout();
}
if (empty($custom)) {
?>
getVersion()); ?>
: ()
diff --git a/view/channel.php b/view/channel.php
index 292737fa8..67c3984d9 100644
--- a/view/channel.php
+++ b/view/channel.php
@@ -1,52 +1,52 @@
getStatus()==='i'){
forbiddenPage(__("This user is inactive"));
}
$isMyChannel = $user_id == User::getId();
AVideoPlugin::getChannel($user_id, $user);
$channelFluidLayout = true;
// verify the width to match with the old profile bg image
$bgImagePath = $global['systemRootPath'] . $user->getBackgroundURL();
$bgSize = getimagesize($bgImagePath);
if($bgSize[0]<2048){
$channelFluidLayout = false;
}
$metaDescription = " Channel - {$_GET['channelName']}";
?>
- :: :: getWebSiteTitle(); ?>
+ getPageTitleSeparator() . __("Channel") . getSEOComplement() . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
">
diff --git a/view/channelProgram.php b/view/channelProgram.php
index 614046568..c2b50ee18 100644
--- a/view/channelProgram.php
+++ b/view/channelProgram.php
@@ -1,604 +1,604 @@
getUsers_id();
}
$user_id = $_GET['user_id'];
$publicOnly = true;
$isMyChannel = false;
if (User::isLogged() && $user_id == User::getId()) {
$publicOnly = false;
$isMyChannel = true;
}
$programs = PlayList::getAllFromUser($user_id, $publicOnly, false, @$_GET['program_id']);
if (empty($programs)) {
$programs = PlayList::getAllFromUser($user_id, $publicOnly);
} else {
$videosArrayId = PlayList::getVideosIdFromPlaylist($_GET['program_id']);
$videos_id = $videosArrayId[0];
}
$playListsObj = AVideoPlugin::getObjectData("PlayLists");
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
$program) {
@$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true);
$videosArrayId = PlayList::getVideosIdFromPlaylist($program['id']);
@$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true);
//getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false, $showUnlisted = false, $activeUsersOnly = true)
if (empty($videosArrayId) && ($program['status'] == "favorite" || $program['status'] == "watch_later")) {
unset($programs[$key]);
continue;
} else if (empty($videosArrayId)) {
$videosP = array();
} else if ($advancedCustom->AsyncJobs) {
$videosP = Video::getAllVideosAsync("viewable", false, true, $videosArrayId, false, true);
} else {
$videosP = Video::getAllVideos("viewable", false, true, $videosArrayId, false, true);
}//var_dump($videosArrayId, $videosP);exit;
@$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true);
//_error_log("channelPlaylist videosP: ".json_encode($videosP));
$videosP = PlayList::sortVideos($videosP, $videosArrayId);
@$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true);
//_error_log("channelPlaylist videosP2: ".json_encode($videosP));
//_error_log("channelPlaylist videosArrayId: ".json_encode($videosArrayId));
$playListButtons = AVideoPlugin::getPlayListButtons($program['id']);
@$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true);
?>
plugin/PlayLists/embed.php?playlists_id=" frameborder="0" allowfullscreen="allowfullscreen" allow="autoplay">'/>
thumbsGif;
$poster = $images->thumbsJpg;
$class = "";
$style = "";
if ($count > 6) {
$class = "showMoreLess{$program['id']}";
$style = "display: none;";
}
?>
label === __("Group")) {
?>
text; ?>
doNotDisplayViews)) {
?>
\ No newline at end of file
diff --git a/view/channels.php b/view/channels.php
index c8926d590..2d0c64a06 100644
--- a/view/channels.php
+++ b/view/channels.php
@@ -1,170 +1,170 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
$value['channelName']);
?>
diff --git a/view/charts.php b/view/charts.php
index 6beaff3da..e3b6d4a75 100644
--- a/view/charts.php
+++ b/view/charts.php
@@ -1,24 +1,24 @@
- Chart - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/configurations.php b/view/configurations.php
index a42c04917..b7fe2a8cb 100644
--- a/view/configurations.php
+++ b/view/configurations.php
@@ -1,35 +1,35 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/contact.php b/view/contact.php
index 60cc63f99..9add31bae 100644
--- a/view/contact.php
+++ b/view/contact.php
@@ -1,161 +1,161 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/downloadExternalVideo.php b/view/downloadExternalVideo.php
index 34abe354a..0d9fa386e 100644
--- a/view/downloadExternalVideo.php
+++ b/view/downloadExternalVideo.php
@@ -1,182 +1,182 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
youtube-dl
Youtube-dl
sudo apt-get install python
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl
diff --git a/view/forbiddenPage.php b/view/forbiddenPage.php
index 3a7ab8e7c..2e229d1c3 100644
--- a/view/forbiddenPage.php
+++ b/view/forbiddenPage.php
@@ -1,27 +1,27 @@
- - getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/help.php b/view/help.php
index 58f0ce24d..6a5500550 100644
--- a/view/help.php
+++ b/view/help.php
@@ -1,114 +1,114 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/iframe.php b/view/iframe.php
index e8cc0e237..9a5858265 100644
--- a/view/iframe.php
+++ b/view/iframe.php
@@ -1,80 +1,84 @@
onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
if (!empty($config->getEncoderURL())) {
$iframeURL = $config->getEncoderURL()."?noNavbar=1&".getCredentialsURL();
}else{
if(empty($iframeURL)){
forbiddenPage("Your encoder is empty");
}
}
}else{
if(empty($iframeURL)){
forbiddenPage("You cannot upload 1");
}
}
break;
case "network":
+ $titleTag = __("Network");
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
if (!empty($advancedCustom->encoderNetwork) && empty($advancedCustom->doNotShowEncoderNetwork)) {
$iframeURL = $advancedCustom->encoderNetwork."?".getCredentialsURL();
}else{
if(empty($iframeURL)){
forbiddenPage("Network is disabled");
}
}
}else{
if(empty($iframeURL)){
forbiddenPage("You cannot upload 1");
}
}
break;
case "log":
+ $titleTag = __("Log");
$iframeURL = $global['webSiteRootURL']."view/logs.php";
break;
}
if(empty($iframeURL)){
forbiddenPage("Invalid Type {$_GET['type']}");
}
?>
- getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/import.php b/view/import.php
index 8b37e7d84..53ea83952 100644
--- a/view/import.php
+++ b/view/import.php
@@ -1,162 +1,162 @@
doNotShowImportMP4Button)) {
return false;
}
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/include/head.php b/view/include/head.php
index f6ccfc470..c39a29983 100644
--- a/view/include/head.php
+++ b/view/include/head.php
@@ -1,172 +1,172 @@
getDescription();
}
if (!empty($poster)) {
$subTitle = str_replace(array('"', "\n", "\r"), array("", "", ""), strip_tags($video['description']));
$custom = array();
$custom[] = $subTitle;
$custom[] = $video["category"];
}
if (!empty($_GET['catName'])) {
$category = Category::getCategoryByName($_GET['catName']);
$description = str_replace(array('"', "\n", "\r"), array("", "", ""), strip_tags($category['description']));
$custom = array();
$custom[] = $description;
$custom[] = $category['name'];
}
foreach ($custom as $key => $value) {
if(empty($value)){
unset($custom[$key]);
}
}
if(!empty($metaDescription)){
$metaDescription = implode(" - ", $custom)." - {$metaDescription}";
}else{
$metaDescription = implode(" - ", $custom);
}
// for SEO to not rise an error of duplicated title or description of same pages with and without last slash
-$metaDescription .= getSEOComplement();
+$metaDescription .= getSEOComplement(array("addAutoPrefix" => false));
$theme = $config->getTheme();
?>
keywords)); ?>">
showCustomCSS) && file_exists($filename)){
echo ' ';
}else{
if($theme !== "default"){
echo "";
}
if(empty($customizePlugin->showCustomCSS)){
echo "";
}
if(!file_exists($filename)){
echo "";
}
echo ' ';
}
$cssFiles = array();
$cssFiles[] = "view/css/main.css";
$cssFiles = array_merge($cssFiles, AVideoPlugin::getCSSFiles());
$cssURL = combineFiles($cssFiles, "css");
?>
getDisable_analytics()) {
?>
getHead();
echo $head;
if (!empty($video)) {
if (!empty($video['users_id'])) {
$userAnalytics = new User($video['users_id']);
echo $userAnalytics->getAnalytics();
unset($userAnalytics);
}
}
ogSite();
?>
diff --git a/view/logs.php b/view/logs.php
index c8be3c1d0..889484291 100644
--- a/view/logs.php
+++ b/view/logs.php
@@ -1,336 +1,336 @@
+
-
...
";
$collapsibleClose = "
";
$outputText = "";
$outputTextErrors = array();
$outputTextWarnings = array();
$linesAdded = 0;
$isCollapsed = true;
function e($text) {
if (empty($text)) {
return false;
}
global $printedarray, $global, $mysqlPass,
$outputText, $outputTextErrors, $outputTextWarnings,
$collapsibleOpen, $collapsibleClose, $linesAdded, $isCollapsed;
$uniqid = "";
$class = "";
$collapsible = true;
$uniqid = uniqid();
if (
preg_match("/(AVideoLog::SECURITY)/", $text, $matches) ||
preg_match("/(Prepare failed)/i", $text, $matches) ||
preg_match("/(AVideoLog::ERROR)/", $text, $matches) ||
preg_match("/(fatal)/i", $text, $matches)) {
$outputTextErrors[] = array($uniqid, $text, $matches[1]);
$class = "terminal-alert terminal-alert-error ";
$style = "background-color: #A00; color:#FFF;font-weight: bold;";
$collapsible = false;
} else
if (preg_match("/(PHP Warning)/i", $text, $matches)) {
$class = "terminal-alert terminal-alert-primary";
$outputTextWarnings[] = array($uniqid, $text, $matches[1]);
$collapsible = false;
} else if (preg_match("/PHP Notice/", $text)) {
$class = "logNotice";
} else if (preg_match("/(AVideoLog::WARNING)/", $text, $matches) || preg_match("/AVideoLog::DEBUG/", $text)) {
$class = "logDebug";
}
if ($collapsible) {
$log = preg_replace("/^[^\]]+/", "", $text);
if (!empty($log)) {
if (in_array($log, $printedarray)) {
$class = "logIgnore";
}
$printedarray[] = $log;
}
}
$removeLinesWithWords = array('password', 'recoverPass', 'pass');
foreach ($removeLinesWithWords as $value) {
if (preg_match("/{$value}/i", $text)) {
$text = preg_replace("/[^ ]/", "*", $text) . " - {$value}";
break;
}
}
$text = preg_replace("/[^ ]+@[^ ]+/i", "myemail@mydomain.com", $text);
$text = htmlentities($text);
if ($collapsible && !$isCollapsed) {
$outputText .= $collapsibleOpen;
$isCollapsed = true;
}
if (!$collapsible && $isCollapsed) {
if ($linesAdded === 0) {
$outputText = "";
} else {
$outputText .= $collapsibleClose;
}
$isCollapsed = false;
}
if (!$collapsible && !$isCollapsed) {
}
$linesAdded++;
$outputText .= ""
. "#{$linesAdded} {$text}"
. "
" . PHP_EOL;
return true;
}
if (empty($global['logfile'])) {
die("Log variable does not exists");
}
if (!file_exists($global['logfile'])) {
die("you may have problems on the write permission for the log file");
}
$lines = tail($global['logfile'], 5000, true, true);
$lines = array_reverse($lines);
foreach ($lines as $key => $line) {
if (empty($line[0])) {
unset($line[$key]);
} else {
break;
}
}
$outputText .= $collapsibleOpen;
foreach ($lines as $line) {
e($line[0]);
}
$outputText .= $collapsibleClose;
?>
- Logs
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
If you have a problem with your installation, feel free to share this log information on GitHub,
on this log we hide all the sensitive information from your log. but it still very helpfull to find issues.
#{$count} - {$value[2]}"; ?>
#{$count} - {$value[2]}";
}
?>
Expand All
Collapse All
\ No newline at end of file
diff --git a/view/managerCategories.php b/view/managerCategories.php
index ce59601bb..8bda67513 100644
--- a/view/managerCategories.php
+++ b/view/managerCategories.php
@@ -1,30 +1,30 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/managerComments.php b/view/managerComments.php
index 5d158f669..8fa424d90 100644
--- a/view/managerComments.php
+++ b/view/managerComments.php
@@ -1,41 +1,41 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/managerPlugins.php b/view/managerPlugins.php
index 2692d8c6a..534059f78 100644
--- a/view/managerPlugins.php
+++ b/view/managerPlugins.php
@@ -1,28 +1,28 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/managerSubscribes.php b/view/managerSubscribes.php
index af7fda968..d1c2f8cd2 100644
--- a/view/managerSubscribes.php
+++ b/view/managerSubscribes.php
@@ -1,141 +1,141 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
..." style="width: 100%;">
diff --git a/view/managerUsers.php b/view/managerUsers.php
index 87a628426..3da7c2bde 100644
--- a/view/managerUsers.php
+++ b/view/managerUsers.php
@@ -1,34 +1,34 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/managerUsersGroups.php b/view/managerUsersGroups.php
index b0e6f80ca..d2bd8aeb3 100644
--- a/view/managerUsersGroups.php
+++ b/view/managerUsersGroups.php
@@ -1,35 +1,35 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/managerVideos.php b/view/managerVideos.php
index c5c4d29b2..09f738db9 100644
--- a/view/managerVideos.php
+++ b/view/managerVideos.php
@@ -1,43 +1,43 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/mini-upload-form/index.php b/view/mini-upload-form/index.php
index b6f505bbf..1939bfd11 100644
--- a/view/mini-upload-form/index.php
+++ b/view/mini-upload-form/index.php
@@ -1,101 +1,101 @@
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
" enctype="multipart/form-data">
encoder or use the public one"); ?>
diff --git a/view/modeYoutube.php b/view/modeYoutube.php
index 24830c95d..358422fb9 100644
--- a/view/modeYoutube.php
+++ b/view/modeYoutube.php
@@ -1,466 +1,461 @@
thumbnails;
$poster = $evideo->thumbnails;
$imgw = 1280;
$imgh = 720;
$autoPlaySources = array();
$autoPlayURL = '';
$autoPlayPoster = '';
$autoPlayThumbsSprit = '';
} else {
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/category.php';
require_once $global['systemRootPath'] . 'objects/subscribe.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
$img = "{$global['webSiteRootURL']}view/img/notfound.jpg";
$poster = "{$global['webSiteRootURL']}view/img/notfound.jpg";
$imgw = 1280;
$imgh = 720;
if (!empty($_GET['type'])) {
if ($_GET['type'] == 'audio') {
$_SESSION['type'] = 'audio';
} else
if ($_GET['type'] == 'video') {
$_SESSION['type'] = 'video';
} else
if ($_GET['type'] == 'pdf') {
$_SESSION['type'] = 'pdf';
} else {
$_SESSION['type'] = "";
unset($_SESSION['type']);
}
} else {
unset($_SESSION['type']);
}
session_write_close();
$modeYouTubeTimeLog['Code part 1'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($_GET['playlist_id'])) {
$isSerie = 1;
if (preg_match("/^[0-9]+$/", $_GET['playlist_id'])) {
$playlist_id = $_GET['playlist_id'];
} else if (User::isLogged()) {
if ($_GET['playlist_id'] == "favorite") {
$playlist_id = PlayList::getFavoriteIdFromUser(User::getId());
} else {
$playlist_id = PlayList::getWatchLaterIdFromUser(User::getId());
}
}
if (!empty($_GET['playlist_index'])) {
$playlist_index = $_GET['playlist_index'];
} else {
$playlist_index = 0;
}
$videosArrayId = PlayList::getVideosIdFromPlaylist($playlist_id);
$videosPlayList = Video::getAllVideos("viewable", false, false, $videosArrayId, false, true);
$videosPlayList = PlayList::sortVideos($videosPlayList, $videosArrayId);
$videoSerie = Video::getVideoFromSeriePlayListsId($playlist_id);
unset($_GET['playlist_id']);
$isPlayListTrailer = false;
$playListObject = AVideoPlugin::getObjectData("PlayLists");
if (!empty($videoSerie)) {
$videoSerie = Video::getVideo($videoSerie["id"], "", true);
if (!empty($playListObject->showTrailerInThePlayList) && !empty($videoSerie["trailer1"]) && filter_var($videoSerie["trailer1"], FILTER_VALIDATE_URL) !== FALSE) {
$videoSerie["type"] = "embed";
$videoSerie["videoLink"] = $videoSerie["trailer1"];
array_unshift($videosPlayList, $videoSerie);
array_unshift($videosArrayId, $videoSerie['id']);
$isPlayListTrailer = true;
}
}
if (empty($playlist_index) && $isPlayListTrailer) {
$video = $videoSerie;
} else {
$vid = new Video("", "", $videosPlayList[$playlist_index]['id']);
$_GET['videoName'] = $vid->getClean_title();
$video = Video::getVideo($videosPlayList[$playlist_index]['id'], "viewable", false, false, false, true);
}
if (!empty($videosPlayList[$playlist_index + 1])) {
$autoPlayVideo = Video::getVideo($videosPlayList[$playlist_index + 1]['id'], "viewableNotUnlisted", false, false, false, true);
$autoPlayVideo['url'] = $global['webSiteRootURL'] . "playlist/{$playlist_id}/" . ($playlist_index + 1);
} else if (!empty($videosPlayList[0])) {
$autoPlayVideo = Video::getVideo($videosPlayList[0]['id'], "viewableNotUnlisted", false, false, false, true);
$autoPlayVideo['url'] = $global['webSiteRootURL'] . "playlist/{$playlist_id}/0";
}
} else {
$catLink = "";
if (!empty($_GET['catName'])) {
$catLink = "cat/{$_GET['catName']}/";
}
// add this because if you change the video category the video was not loading anymore
$catName = @$_GET['catName'];
if (empty($_GET['clean_title']) && (isset($advancedCustom->forceCategory) && $advancedCustom->forceCategory === false)) {
$_GET['catName'] = "";
}
if (empty($video)) {
$video = Video::getVideo("", "viewable", false, false, true, true);
}
if (empty($video)) {
$video = Video::getVideo("", "viewable", false, false, false, true);
}
if (empty($video)) {
$video = AVideoPlugin::getVideo();
}
if (!empty($_GET['v']) && (empty($video) || $video['id'] != $_GET['v'])) {
$video = false;
}
if(!empty($video['id'])){
// allow users to count a view again in case it is refreshed
Video::unsetAddView($video['id']);
// add this because if you change the video category the video was not loading anymore
$_GET['catName'] = $catName;
$_GET['isMediaPlaySite'] = $video['id'];
$obj = new Video("", "", $video['id']);
}
/*
if (empty($_SESSION['type'])) {
$_SESSION['type'] = $video['type'];
}
*
*/
// $resp = $obj->addView();
$get = array('channelName' => @$_GET['channelName'], 'catName' => @$_GET['catName']);
$modeYouTubeTimeLog['Code part 1.1'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($video['next_videos_id'])) {
$modeYouTubeTimeLog['Code part 1.2'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
$autoPlayVideo = Video::getVideo($video['next_videos_id']);
} else {
$modeYouTubeTimeLog['Code part 1.3'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
/*
if ($video['category_order'] == 1) {
$modeYouTubeTimeLog['Code part 1.4'] = microtime(true)-$modeYouTubeTime;
$modeYouTubeTime = microtime(true);
unset($_POST['sort']);
$category = Category::getAllCategories();
$_POST['sort']['title'] = "ASC";
$modeYouTubeTimeLog['Code part 1.4.1'] = microtime(true)-$modeYouTubeTime;
$modeYouTubeTime = microtime(true);
// maybe there's a more slim method?
$videos = Video::getAllVideos();
$videoFound = false;
$autoPlayVideo;
foreach ($videos as $value) {
if ($videoFound) {
$autoPlayVideo = $value;
break;
}
if ($value['id'] == $video['id']) {
// if the video is found, make another round to have the next video properly.
$videoFound = true;
}
}
} else {
*
*/
$modeYouTubeTimeLog['Code part 1.5'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if(!empty($video['id'])){
$autoPlayVideo = Video::getRandom($video['id']);
}
//}
}
$modeYouTubeTimeLog['Code part 1.6'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($autoPlayVideo)) {
$name2 = User::getNameIdentificationById($autoPlayVideo['users_id']) . ' ' . User::getEmailVerifiedIcon($autoPlayVideo['users_id']);
$autoPlayVideo['creator'] = '';
$autoPlayVideo['tags'] = Video::getTags($autoPlayVideo['id']);
//$autoPlayVideo['url'] = $global['webSiteRootURL'] . $catLink . "video/" . $autoPlayVideo['clean_title'];
$autoPlayVideo['url'] = Video::getLink($autoPlayVideo['id'], $autoPlayVideo['clean_title'], false, $get);
}
}
$modeYouTubeTimeLog['Code part 2'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($video)) {
$name = User::getNameIdentificationById($video['users_id']);
$name = "{$name} " . User::getEmailVerifiedIcon($video['users_id']) . " ";
$subscribe = Subscribe::getButton($video['users_id']);
$video['creator'] = '';
$obj = new Video("", "", $video['id']);
// dont need because have one embeded video on this page
// $resp = $obj->addView();
}
if (!empty($video) && $video['type'] == "video") {
$poster = "{$global['webSiteRootURL']}videos/{$video['filename']}.jpg";
} else {
$poster = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
if (!empty($video)) {
$source = Video::getSourceFile($video['filename']);
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) {
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else if ($video['type'] == "audio") {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$type = 'video';
if ($video['type'] === 'pdf') {
$type = 'pdf';
} else if ($video['type'] === 'zip') {
$type = 'zip';
} else if ($video['type'] === 'article') {
$type = 'article';
}
$images = Video::getImageFromFilename($video['filename'], $type);
$poster = isMobile() ? $images->thumbsJpg : $images->poster;
if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') {
$img = $images->posterPortrait;
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = isMobile() ? $images->thumbsJpg : $images->poster;
}
} else {
$poster = "{$global['webSiteRootURL']}view/img/notfound.jpg";
}
$objSecure = AVideoPlugin::getObjectDataIfEnabled('SecureVideosDirectory');
$modeYouTubeTimeLog['Code part 3'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (!empty($autoPlayVideo) && !empty($autoPlayVideo['filename'])) {
$autoPlaySources = getSources($autoPlayVideo['filename'], true);
$autoPlayURL = $autoPlayVideo['url'];
$autoPlayPoster = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}.jpg";
$autoPlayThumbsSprit = "{$global['webSiteRootURL']}videos/{$autoPlayVideo['filename']}_thumbsSprit.jpg";
} else {
$autoPlaySources = array();
$autoPlayURL = '';
$autoPlayPoster = '';
$autoPlayThumbsSprit = "";
}
if (empty($_GET['videoName'])) {
$_GET['videoName'] = $video['clean_title'];
}
$v = Video::getVideoFromCleanTitle($_GET['videoName']);
$modeYouTubeTimeLog['Code part 4'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
AVideoPlugin::getModeYouTube($v['id']);
$modeYouTubeTimeLog['Code part 5'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
if (empty($video)) {
header('HTTP/1.0 404 Not Found', true, 404);
}
$modeYouTubeTimeLog['Code part 6'] = microtime(true) - $modeYouTubeTime;
$modeYouTubeTime = microtime(true);
}
// video not found
if (empty($video)) {
$img = "{$global['webSiteRootURL']}view/img/this-video-is-not-available.jpg";
$poster = "{$global['webSiteRootURL']}view/img/this-video-is-not-available.jpg";
$imgw = 1280;
$imgh = 720;
unset($_SESSION['type']);
session_write_close();
$video = array();
$video['id'] = 0;
$video['type'] = 'notfound';
$video['rotation'] = 0;
$video['videoLink'] = "";
$video['title'] = __("Video Not Available");
$video['clean_title'] = "video-not-available";
$video['description'] = "";
$video['duration'] = "";
$video['creator'] = "";
$video['likes'] = "";
$video['dislikes'] = "";
$video['category'] = "embed";
$video['views_count'] = 0;
$video['filename'] = "";
header('HTTP/1.0 404 Not Found', true, 404);
}
$metaDescription = " {$video['id']}";
// make sure the title tag does not have more then 70 chars
-$titleTag = "{$video['title']}";
-if (strlen($titleTag) > 50) {
- $titleTag = substr($titleTag, 0, 50);
-} else {
- $titleTag .= " - " . $config->getWebSiteTitle();
-}
-$titleTag = substr($titleTag, 0, 60);
-$titleTag .= " - " . getSEOComplement();
-$titleTag = substr($titleTag, 0, 70);
+$titleTag = $video['title'];
+$titleTag = (strlen($titleTag) > 50) ? (substr($titleTag, 0, 48) . " …") : $titleTag;
+$titleTag .= getSEOComplement(array("allowedTypes" => array("audio", "video", "pdf"))) . $config->getPageTitleSeparator() . $config->getWebSiteTitle();
+$titleTag = (strlen($titleTag) > 70) ? (substr($titleTag, 0, 68) . " …") : $titleTag;
if (!empty($video['users_id']) && User::hasBlockedUser($video['users_id'])) {
$video['type'] = "blockedUser";
}
?>
showChannelBannerOnModeYoutube)) {
?>
! videoNotFoundText->value) ? __("We have not found any videos or audios to show") : $advancedCustom->videoNotFoundText->value; ?>.
disableYoutubePlayerIntegration;
} else {
$disableYoutubeIntegration = false;
}
if ((isset($_GET['isEmbedded'])) && ($disableYoutubeIntegration == false)) {
if ($_GET['isEmbedded'] == "y") {
?>
$value) {
if ($value > 0.5) {
echo "*** ";
}
echo "{$key} = {$value} seconds \n";
}
echo "\n -->";
?>
diff --git a/view/signUp.php b/view/signUp.php
index 61a3b29c9..73a7dea45 100644
--- a/view/signUp.php
+++ b/view/signUp.php
@@ -1,208 +1,208 @@
disableNativeSignUp)) {
die(__("Sign Up Disabled"));
}
$agreement = AVideoPlugin::loadPluginIfEnabled("SignUpAgreement");
$signInLink = "{$global['webSiteRootURL']}user?redirectUri=".urlencode(isset($_GET['redirectUri']) ? $_GET['redirectUri'] : "");
if(!empty($_GET['siteRedirectUri'])){
$signInLink = $_GET['siteRedirectUri'];
}
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
forceLoginToBeTheEmail)) {
?>
getSignupCheckBox();
}
?>
diff --git a/view/trending.php b/view/trending.php
index eaa86326d..aaf15aaf4 100644
--- a/view/trending.php
+++ b/view/trending.php
@@ -1,239 +1,239 @@
- getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
diff --git a/view/update.php b/view/update.php
index d63f48489..a2fa4efd5 100644
--- a/view/update.php
+++ b/view/update.php
@@ -1,200 +1,200 @@
- getWebSiteTitle(); ?>
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
getVersion()); ?>
Version {$value['version']}";
$disabled = "disabled";
}
?>
" . count($updateFiles) . ""); ?>
Our repository is now running at version version; ?>.
You can follow this
Update Tutorial
to update your files and get the latest version.
error = "";
foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '')
continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';') {
if (!$global['mysqli']->query($templine)) {
$obj->error = ('Error performing query \'
' . $templine . '\': ' . $global['mysqli']->error . ' ');
echo json_encode($obj);
//exit;
}
$templine = '';
}
}
// insert configuration if is version 1.0
if ($config->currentVersionLowerThen('1.0')) {
$sql = "DELETE FROM configurations WHERE id = 1 ";
if ($global['mysqli']->query($sql) !== TRUE) {
$obj->error = "Error deleting configuration: " . $global['mysqli']->error;
echo json_encode($obj);
exit;
}
$sql = "INSERT INTO configurations (id, video_resolution, users_id, version, created, modified) VALUES (1, '426:240', " . User::getId() . ",'1.0', now(), now())";
if ($global['mysqli']->query($sql) !== TRUE) {
$obj->error = "Error creating configuration: " . $global['mysqli']->error;
echo json_encode($obj);
exit;
}
}
if ($config->currentVersionEqual('1.0')) {
$sql = "UPDATE configurations SET users_id = " . User::getId() . ", version = '1.1', webSiteTitle = '{$global['webSiteTitle']}', language = '{$global['language']}', contactEmail = '{$global['contactEmail']}', modified = now() WHERE id = 1";
if ($global['mysqli']->query($sql) !== TRUE) {
$obj->error = "Error creating configuration: " . $global['mysqli']->error;
echo json_encode($obj);
exit;
}
}
//$renamed = rename("{$global['systemRootPath']}updateDb.sql", "{$global['systemRootPath']}updateDb.sql.old");
?>
diff --git a/view/user.php b/view/user.php
index 3b80bc9e0..7828eedb4 100644
--- a/view/user.php
+++ b/view/user.php
@@ -1,105 +1,107 @@
type} fix-width\">{$value->text}";
}
//$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php");
// convert the string to a json object
//$advancedCustom = json_decode($json_file);
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
loadSelfUser();
?>
disablePersonalInfo)) { ?>
getId()); ?>
disablePersonalInfo)) { ?>
getId()); ?>
diff --git a/view/videoEmbeded.php b/view/videoEmbeded.php
index b8cc68e5b..f53bb101c 100644
--- a/view/videoEmbeded.php
+++ b/view/videoEmbeded.php
@@ -1,567 +1,567 @@
thumbnails;
$poster = $evideo->thumbnails;
$imgw = 1280;
$imgh = 720;
$autoPlaySources = array();
$autoPlayURL = '';
$autoPlayPoster = '';
$autoPlayThumbsSprit = '';
} else if (!empty($_GET['v'])) {
$video = Video::getVideo($_GET['v'], "", true, false, false, true);
//$video['id'] = $_GET['v'];
} else if (!empty($_GET['videoName'])) {
$video = Video::getVideoFromCleanTitle($_GET['videoName']);
}
Video::unsetAddView($video['id']);
AVideoPlugin::getEmbed($video['id']);
if (empty($video)) {
forbiddenPage("Video not found");
}
if (empty($customizedAdvanced)) {
$customizedAdvanced = AVideoPlugin::getObjectDataIfEnabled('CustomizeAdvanced');
}
if (!isSameDomain(@$_SERVER['HTTP_REFERER'], $global['webSiteRootURL']) && !isAVideoMobileApp()) {
if (!empty($advancedCustomUser->blockEmbedFromSharedVideos) && !CustomizeUser::canShareVideosFromVideo($video['id'])) {
if(!empty($advancedCustomUser->blockEmbedFromSharedVideos)){
error_log("Embed is forbidden: \$advancedCustomUser->blockEmbedFromSharedVideos");
}
if(!CustomizeUser::canShareVideosFromVideo($video['id'])){
error_log("Embed is forbidden: !CustomizeUser::canShareVideosFromVideo(\$video['id'])");
}
forbiddenPage("Embed is forbidden");
}
}
$imgw = 1280;
$imgh = 720;
if ($video['type'] !== "pdf") {
$source = Video::getSourceFile($video['filename']);
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio")) {
$source = Video::getSourceFile($video['filename']);
$img = $source['url'];
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
} else {
$img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
$images = Video::getImageFromFilename($video['filename']);
$poster = $images->poster;
if (!empty($images->posterPortrait)) {
$img = $images->posterPortrait;
$data = getimgsize($source['path']);
$imgw = $data[0];
$imgh = $data[1];
}
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
/*
* Swap aspect ratio for rotated (vvs) videos
if ($video['rotation'] === "90" || $video['rotation'] === "270") {
$embedResponsiveClass = "embed-responsive-9by16";
$vjsClass = "vjs-9-16";
} else {
$embedResponsiveClass = "embed-responsive-16by9";
$vjsClass = "vjs-16-9";
} */
$vjsClass = "";
$obj = new Video("", "", $video['id']);
$resp = $obj->addView();
if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio")) {
$poster = "{$global['webSiteRootURL']}videos/{$video['filename']}.jpg";
} else {
$poster = "{$global['webSiteRootURL']}view/img/audio_wave.jpg";
}
//https://.../vEmbed/527?modestbranding=1&showinfo=0&autoplay=1&controls=0&loop=1&mute=1&t=0
$modestbranding = false;
$autoplay = false;
$controls = "controls";
$loop = "";
$mute = "";
$objectFit = "";
$t = 0;
if (isset($_GET['modestbranding']) && $_GET['modestbranding'] == "1") {
$modestbranding = true;
}
if (!empty($_GET['autoplay']) || $config->getAutoplay()) {
$autoplay = true;
}
if (isset($_GET['controls']) && $_GET['controls'] == "0") {
$controls = "";
}
if (!empty($_GET['loop'])) {
$loop = "loop";
}
if (!empty($_GET['mute'])) {
$mute = 'muted="muted"';
}
if (!empty($_GET['objectFit'])) {
$objectFit = 'object-fit: ' . $_GET['objectFit'];
}
if (!empty($_GET['t'])) {
$t = intval($_GET['t']);
} else if (!empty($video['progress']['lastVideoTime'])) {
$t = intval($video['progress']['lastVideoTime']);
} else if (!empty($video['externalOptions']->videoStartSeconds)) {
$t = parseDurationToSeconds($video['externalOptions']->videoStartSeconds);
}
$playerSkinsO = AVideoPlugin::getObjectData("PlayerSkins");
$disableEmbedTopInfo = $playerSkinsO->disableEmbedTopInfo;
$url = Video::getLink($video['id'], $video['clean_title'], false);
$title = str_replace('"', '', $video['title']) . ' - ' . $config->getWebSiteTitle();
$photo = User::getPhoto($video['users_id']);
if (empty($currentTime)) {
$currentTime = 0;
}
if (User::hasBlockedUser($video['users_id'])) {
$disableEmbedTopInfo = true;
$video['type'] = "blockedUser";
}
?>
- getWebSiteTitle(); ?> ::
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
You've blocked user ()
You won't see any comments or videos from this user
" class="img img-responsive" style="height: 100%;" >
open($sources['zip']["path"]);
for ($i = 0; $i < $za->numFiles; $i++) {
$stat = $za->statIndex($i);
$fname = basename($stat['name']);
?>
class="center-block video-js vjs-default-skin vjs-big-play-centered" id="mainVideo" data-setup='{ "fluid": true }'
poster="view/img/recorder.gif">
horse
horse
class="video-js vjs-default-skin vjs-big-play-centered " id="mainVideo">
" >
";
echo getVTTTracks($video['filename']);
}
?>
class="video-js vjs-default-skin vjs-big-play-centered " id="mainVideo">
' . $subscribe . '